Ingress Controller安装官方说明文档。
对于裸机即虚拟机可以使用如下方法创建资源:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/baremetal/deploy.yaml
提示:
若无法下载可能是国内网络访问外global网部分限制的原因,笔者实在其他linux服务器下载deploy.yaml文件和相关镜像导入后使用的,如果需要可以关注微信公众号“琼杰笔记”,回复“ingress”免费获取。
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/baremetal/deploy.yaml
通过yaml清单创建ingress资源:
apiVersion: v1 kind: Service metadata: name: myapp namespace: default spec: selector: app: myapp release: canary ports: - name: http targetPort: 80 port: 80 --- apiVersion: apps/v1 kind: Deployment metadata: name: myapp-deploy namespace: default spec: replicas: 3 selector: matchLabels: app: myapp release: canary template: metadata: labels: app: myapp release: canary spec: containers: - name: myapp image: ikubernetes/myapp:v2 ports: - name: http containerPort: 80
查看pod资源
[root@master1 bare-metal]# kubectl get pods -n ingress-nginx NAME READY STATUS RESTARTS AGE ingress-nginx-admission-create-7tw8l 0/1 Completed 0 20m ingress-nginx-admission-patch-pwgnp 0/1 Completed 1 20m ingress-nginx-controller-69fb496d7d-cfhgs 1/1 Running 0 20m [root@master1 bare-metal]# kubectl get svc -n ingress-nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller NodePort 10.101.227.57 <none> 80:30805/TCP,443:31386/TCP 21m ingress-nginx-controller-admission ClusterIP 10.101.31.83 <none> 443/TCP 21m
通过ingress发布服务:
评论前必须登录!
注册