// 国内被墙 
// 增加几个仓库
NAME            URL                                                       
stable          https://charts.helm.sh/stable                             
ingress-nginx   https://kubernetes.github.io/ingress-nginx                
aliyun          https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts    
repo_name1      https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator
gitlab          https://charts.gitlab.io/                                 
apphub          https://apphub.aliyuncs.com 

// 方法一: 开启全局代理 把不能下载的镜像下载到本地

// 方法二: 
helm search repo nginx

helm pull ingress-nginx/ingress-nginx

tar -zxvf xxxx.tgz

cd ingress-nginx

vi values.yaml

修改镜像仓库地址为:
controller:
  name: controller
  image:
    repository: registry.cn-hangzhou.aliyuncs.com/kubeapps/quay-nginx-ingress-controller
    tag: "0.28.0"
    pullPolicy: IfNotPresent
    # www-data -> uid 101
    runAsUser: 101
    allowPrivilegeEscalation: true


// 保存退出
执行命令
helm insatll nginx-ingress nginx-ingress 

// 安装成功


// 如果你需要在不同的节点自由选择安装ingress

// 继续修改value.yaml
修改:
  ## DaemonSet or Deployment
  ##
  kind: DaemonSet
  
修改:
  ## Node labels for controller pod assignment
  ## Ref: https://kubernetes.io/docs/user-guide/node-selection/
  ##
  nodeSelector:
    kubernetes.io/os: linux
    ingress: "true"

// 含义为只有被打上了 ingress = true 的节点才会被安装ingress

// 执行
kubectl label node k8s-nodeX ingress=true

// 执行安装命令即可

// 示例
ingress-example.yaml
 
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingressClass: "nginx"
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx-svc
          servicePort: 80

// 创建一个nginx的Deployment
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
  labels:
    app: nginx-svc
spec:
  selector:
    app: nginx
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    app: nginx
  name: nginx
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 2 #副本数
  revisionHistoryLimit: 10 # 历史记录保留的个数
  selector:
    matchLabels:
      app: nginx
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.15.2
        imagePullPolicy: IfNotPresent
        name: nginx
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      restartPolicy: Always
      terminationGracePeriodSeconds: 30

// 创建
kubectl create -f ingress-example.yaml

//查看
kubectl get ingress

Last modification:January 15, 2021
If you think my article is useful to you, please feel free to appreciate