k8s 配置ingress-nginx

下载镜像时间太长我手动导入镜像

# docker load -i nginx.tar.gz
861ac8268e83: Loading layer [==================================================>]     54MB/54MB
65108a495798: Loading layer [==================================================>]  26.45MB/26.45MB
b0f2b459d4e3: Loading layer [==================================================>]  1.931MB/1.931MB
dc166b174efb: Loading layer [==================================================>]  330.1MB/330.1MB
e3e97f070635: Loading layer [==================================================>]  728.6kB/728.6kB
b87f06926b0d: Loading layer [==================================================>]  43.05MB/43.05MB
17b3679fe89a: Loading layer [==================================================>]  8.192kB/8.192kB
2bb74ea2be4a: Loading layer [==================================================>]   2.56kB/2.56kB
f1980a0b3af3: Loading layer [==================================================>]  6.144kB/6.144kB
74e8ef22671f: Loading layer [==================================================>]  35.78MB/35.78MB
6dd0b74b8a3e: Loading layer [==================================================>]  21.37MB/21.37MB
6bcbfd84ac45: Loading layer [==================================================>]  7.168kB/7.168kB
Loaded image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.25.0

部署ingress-nginx:

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
namespace/ingress-nginx created
configmap/nginx-configuration created
configmap/tcp-services created
configmap/udp-services created
serviceaccount/nginx-ingress-serviceaccount created
clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created
role.rbac.authorization.k8s.io/nginx-ingress-role created
rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created
clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created
deployment.apps/nginx-ingress-controller created

查看nginx控制器pod状态

kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch
NAME                                        READY   STATUS    RESTARTS   AGE
nginx-ingress-controller-7995bd9c47-gt97s   1/1     Running   0          49s

部署ingress-nginx nodeport 类型service

# cat nginx-ingress-svc.yaml
apiVersion: v1
kind: Service
metadata: 
  name: nginx-ingress-controller
  namespace: ingress-nginx
spec:
  type: NodePort
  clusterIP: 10.254.99.99
  ports:
  - name: http
    port: 80
    nodePort: 30080
  - name: https
    port: 443
    nodePort: 30443
  selector:
    app.kubernetes.io/name: ingress-nginx

发表评论

电子邮件地址不会被公开。 必填项已用*标注