|
步骤 根据不同的域名实现虚拟主机 |
1、创建ingress-vh 虚拟主机文件夹 |
2、到ingress-vh创建 deployment1.yaml
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: deployment1 spec: replicas: 2 template: metadata: labels: name: nginx spec: containers: - name: nginx image: hub.lqz.com/library/nginx:latest imagePullPolicy: IfNotPresent ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: svc-1 spec: ports: - port: 80 targetPort: 80 protocol: TCP selector: name: nginx
|
创建:kubectl apply -f deployment1.yaml |
查看:kubectl get svc |
连接测试:curl **** |
复制成第二个dployment cp -a deployment1yaml deployment2.yaml |
第二个deployment deployment2.yaml
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: deployment2 spec: replicas: 2 template: metadata: labels: name: nginx2 #name标签不能一致 spec: containers: - name: nginx2 image: hub.lqz.com/library/nginx:v2 imagePullPolicy: IfNotPresent ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: svc-2 spec: ports: - port: 80 targetPort: 80 protocol: TCP selector: name: nginx2
|
vim ingressrule.yaml 多个yaml文件可以写在一起,中间通过---隔开即可 |
apiVersion: extensions/v1beta1 kind: Ingress metadata: name:ingress1 spec: rules: - host: www1.atguigu.com http: paths: - path: / backend: serviceName: svc-1 servicePort: 80 --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name:ingress2 spec: rules: - host: www2.atguigu.com http: paths: - path: / backend: serviceName: svc-2 servicePort: 80
|
运行ingressrule.yaml:kubectl apply -f ingressrule.yaml |
查看:kubect get pod -n ingress-nginx |
进入 ingress容器查看: kubectl exec 容器名 -n ingress-nginx -it -- /bin/bash 查看 cat nginx.conf |
kubectl get ingress |
链接:https://www.bilibili.com/video/av66617940/?p=14