亲宝软件园·资讯

展开

安装ingress-nginx坑

令溶炎 人气:0

环境:

Linux:CentOS Linux release 7.9.2009 (Core)

Kubernetes:v1.23.5

Dokcer:20.10.14

一、安装ingress-nginx

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml

二、修改deploy.yaml文件

1、注释掉external Traffic Policy:Local

2、因默认镜像源国内无法访问 ,修改为dockerhub上的镜像源

修改controller/deploy的image:

image: bitnami/nginx-ingress-controller:1.1.2

 修改ingress.nginx-admission-create的image:

image: liangjw/kube-webhook-certgen:v1.1.1

 修改ingress-nginx-admission-patch的image:

image: liangjw/kube-webhook-certgen:v1.1.1

三、部署ingress-nginx

# kubectl apply -f deploy.yaml
查看pods部署状态
# kubectl get pods -n ingress-nginx -w
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-2mp7n        0/1     Completed   0          3s
ingress-nginx-admission-patch-xrdf5         0/1     Completed   0          3s
ingress-nginx-controller-859fb9b444-zq4n6   0/1     Running     0          3s
ingress-nginx-controller-859fb9b444-zq4n6   1/1     Running     0          20s

部署过程中可能遇到的报错如下

1、ingress-nginx-admission-create和ingress-nginx-admission-patch部署失败,报错如下

# kubectl logs -n ingress-nginx ingress-nginx-admission-create-bj4d4
W0418 01:48:48.738693       1 client_config.go:615] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
{"err":"Get \"https://10.20.0.1:443/api/v1/namespaces/ingress-nginx/secrets/ingress-nginx-admission\": dial tcp 10.20.0.1:443: i/o timeout","level":"fatal","msg":"error getting secret","source":"k8s/k8s.go:232","time":"2022-04-18T01:49:18Z"}

解决方法:

在deploy.yaml中Ingress-nginx-admission-create和Ingress-nginx-admission-patch的Job资源下的spec.template.spec中添加如下hostNetwork: true,重新部署

 2、ingress-nginx-controller报错如下:

# kubectl describe pod -n ingress-nginx ingress-nginx-controller-55bc668cd8-fbrjn
  Warning  FailedMount  8m51s (x3 over 8m53s)   kubelet            MountVolume.SetUp failed for volume "webhook-cert" : secret "ingress-nginx-admission" not found
  Normal   Pulled       8m11s (x4 over 8m45s)   kubelet            Container image "registry.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.2@sha256:dcbc1b017e63a50ef369c4827d2d92334dce13ca0966712de45a8661ba97bc32" already present on machine
 
# kubectl logs -f ingress-nginx-controller-55bc668cd8-fbrjn -n ingress-nginx
standard_init_linux.go:228: exec user process caused: exec format error

 报错原因:镜像版本和环境版本不匹配,使用的阿里云的镜像,但是架构不一样,更换镜像为上面第二步中的镜像

3、更换镜像之后再次部署时,ingress-nginx-controller报错如下

# kubectl logs -f -n ingress-nginx ingress-nginx-controller-6b
W0418 07:38:49.717651       1 client_config.go:615] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0418 07:38:49.717901       1 main.go:223] "Creating API client" host="https://10.20.0.1:443"

这次的报错同ingress-nginx-admission-create报错,在ingress-nginx-controller的Deployment中spec.template.spec中添加如下hostNetwork: true

修改完成后,重新部署即可 

总结

加载全部内容

相关教程
猜你喜欢
用户评论