解决国内k8s的ingress-nginx镜像⽆法正常pull拉取问题⽬录
⼀、问题描述
⼆、解决⽅法
⼀、问题描述
我们期望运⾏Ingress就必须给我们的集创建Ingress controller
⽬前官⽅推荐的controller有:[⽬前⽀持和维护,和 Ingress 控制器]
# 不使⽤helm,使⽤yaml
kubectl apply -f raw.githubusercontent/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml
注意,不同的版本适应的k8s版本不同,详细见表格:(根据你的k8s版本选择⽀持的版本,替换上⾯的v1.1.1,我的是1.23)
Ingress-NGINX version k8s supported version Alpine Version Nginx Version
v1.1.1  1.23, 1.22, 1.21, 1.20, 1.193.14.2  1.19.9†
v1.1.0  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.5  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.4  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.3  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.2  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.1  1.22, 1.21, 1.20, 1.19  3.14.2  1.19.9†
v1.0.0  1.22, 1.21, 1.20, 1.19  3.13.5  1.20.1
v0.50.0  1.21, 1.20, 1.19  3.14.2  1.19.9†
v0.49.3  1.21, 1.20, 1.19  3.14.2  1.19.9†
v0.49.2  1.21, 1.20, 1.19  3.14.2  1.19.9†
v0.49.1  1.21, 1.20, 1.19  3.14.2  1.19.9†
v0.49.0  1.21, 1.20, 1.19  3.13.5  1.20.1
v0.48.1  1.21, 1.20, 1.19  3.13.5  1.20.1
v0.47.0  1.21, 1.20, 1.19  3.13.5  1.20.1
v0.46.0  1.21, 1.20, 1.19  3.13.2  1.19.6
但是官⽅给出的yaml⽂件中拉取的镜像不在docker hub中,在io中,所以在国内我们拉取就会报错:ErrImagePull
$ k describe pod/ingress-nginx-admission-create-8zv9w
...
...
Events:
Type    Reason          Age                From              Message
----    ------          ----                ----              -------
Normal  Scheduled      16m                default-scheduler  Successfully assigned ingress-nginx/ingress-nginx-admissio
n-create-8zv9w to node2
Normal  Pulling        14m (x4 over 16m)  kubelet            Pulling image "io/ingress-nginx/kube-webhook-certg
en:v1.1.1@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660"
Warning  Failed          14m (x4 over 16m)  kubelet            Failed to pull image "io/ingress-nginx/kube-webhoo
k-certgen:v1.1.1@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660": rpc error: code = Unknown desc =
Error response from daemon: Get "io/v2/": net/http: request canceled while waiting for connection (Client.Ti
meout exceeded while awaiting headers)
Warning  Failed          14m (x4 over 16m)  kubelet            Error: ErrImagePull
Normal  BackOff        77s (x58 over 16m)  kubelet            Back-off pulling image "io/ingress-nginx/kube-webh
ook-certgen:v1.1.1@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660"
issue中官⽅⼈员说没法上传到docker hub,可能也有⾃⼰的苦衷吧。。。
⼆、解决⽅法
解决⽅法很简单,⽤国内好⼼⼈搬运到docker hub上的仓库代替
还可以⼿动发issue让其更新,以后gcr.io或io仓库的都可以在此更换
所以,v1.1.1版本的修改过的镜像的完整yaml⽂件如下:(我已经帮你好了),如果你要使⽤其他版本ingress控制器,请在该docker hub上⾃⼰寻替换,如果不是最新⾃⼰发issue拉取
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
---
# Source: ingress-nginx/templates/controller-serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx
namespace: ingress-nginx automountServiceAccountToken: true
---
# Source: ingress-nginx/templates/controller-configmap.yaml apiVersion: v1
kind: ConfigMap
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx-controller
namespace: ingress-nginx
data:
allow-snippet-annotations: 'true'
---
# Source: ingress-nginx/templates/clusterrole.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
name: ingress-nginx
rules:
- apiGroups:
-
''
resources:
- configmaps
- endpoints
- nodes
- pods
- secrets
- namespaces
verbs:
- list
- watch
-
apiGroups:
- ''
resources:
- nodes
verbs:
- get
- apiGroups:
- ''
resources:
- services
verbs:
-
get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
-
apiGroups:
- ''
resources:
- patch
- apiGroups:
- networking.k8s.io
resources:
- ingresses/status
verbs:
- update
- apiGroups:
-
networking.k8s.io
resources:
- ingressclasses
verbs:
- get
- list
- watch
---
# Source: ingress-nginx/templates/clusterrolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
name: ingress-nginx
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: ingress-nginx
subjects:
- kind: ServiceAccount
name: ingress-nginx
namespace: ingress-nginx
---
# Source: ingress-nginx/templates/controller-role.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx
namespace: ingress-nginx
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- apiGroups:
- ''
resources:
- configmaps
- pods
- secrets
- endpoints
verbs:
- get
-
list
- watch
- apiGroups:
- ''
resources:
- services
verbs:
- get
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingresses/status
verbs:
- update
- apiGroups:
-
networking.k8s.io
resources:
- ingressclasses
verbs:
- get
- list
- watch
- apiGroups:
- ''
resources:
- configmaps
resourceNames:
- ingress-controller-leader
verbs:
- get
- update
- apiGroups:
- ''
resources:
- configmaps
verbs:
- create
-
apiGroups:
- ''
resources:
- events
verbs:
- create
- patch
---
# Source: ingress-nginx/templates/controller-rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.1.1
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx
namespace: ingress-nginx
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ingress-nginxreactorloadbalancer
subjects:
- kind: ServiceAccount
name: ingress-nginx
namespace: ingress-nginx
---
# Source: ingress-nginx/templates/controller-service-webhook.yaml apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.15
app.kubernetes.io/name: ingress-nginx

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。