一、Rancher使用Helm安装Ingress控制器

1、依次点击【应用】-【Chart】,搜索Ingress,选择【NGINX Ingress Controller】

image-20250112190552063

2、选择11.0.0版本后,点击【安装】

image-20250112190701343

3、创建名为ingress-nginx的新命名空间,勾选【在安装前自定义Helm选项】后,点击【下一步】

image-20250112190856358

4、编辑选项这块修改镜像nginx/nginx-ingress为国内镜像registry.cn-hangzhou.aliyuncs.com/abroad_images/nginx-ingress,点击【下一步】

修改后的地方如下:

#82-83修改镜像为国内镜像
    registry: registry.cn-hangzhou.aliyuncs.com
    repository: abroad_images/nginx

#182-183修改镜像为国内镜像
  registry: registry.cn-hangzhou.aliyuncs.com
  repository: abroad_images/nginx-ingress-controller
#318行修改服务类型为NodePort
  type: NodePort

修改完整体配置如下:

addHeaders: {}
affinity: {}
allowSnippetAnnotations: true
args: []
automountServiceAccountToken: true
autoscaling:
  enabled: false
  maxReplicas: 11
  minReplicas: 1
  targetCPU: ''
  targetMemory: ''
clusterDomain: cluster.local
command: []
commonAnnotations: {}
commonLabels: {}
config: {}
configMapNamespace: ''
containerPorts:
  http: 8080
  https: 8443
  metrics: 10254
containerSecurityContext:
  allowPrivilegeEscalation: false
  capabilities:
    add:
      - NET_BIND_SERVICE
    drop:
      - ALL
  enabled: true
  readOnlyRootFilesystem: true
  runAsGroup: 1001
  runAsNonRoot: true
  runAsUser: 1001
  seLinuxOptions: null
  seccompProfile:
    type: RuntimeDefault
customLivenessProbe: {}
customReadinessProbe: {}
customStartupProbe: {}
customTemplate:
  configMapKey: ''
  configMapName: ''
daemonset:
  hostPorts:
    http: 80
    https: 443
  useHostPort: false
defaultBackend:
  affinity: {}
  args: []
  automountServiceAccountToken: true
  command: []
  containerPort: 8080
  containerSecurityContext:
    allowPrivilegeEscalation: false
    capabilities:
      drop:
        - ALL
    enabled: true
    readOnlyRootFilesystem: true
    runAsGroup: 1001
    runAsNonRoot: true
    runAsUser: 1001
    seLinuxOptions: null
    seccompProfile:
      type: RuntimeDefault
  customLivenessProbe: {}
  customReadinessProbe: {}
  customStartupProbe: {}
  enabled: true
  extraArgs: {}
  extraEnvVars: []
  extraEnvVarsCM: ''
  extraEnvVarsSecret: ''
  extraVolumeMounts: []
  extraVolumes: []
  hostAliases: []
  image:
    digest: ''
    pullPolicy: IfNotPresent
    pullSecrets: []
    registry: registry.cn-hangzhou.aliyuncs.com
    repository: abroad_images/nginx
    tag: 1.25.4-debian-12-r3
  initContainers: []
  lifecycleHooks: {}
  livenessProbe:
    enabled: true
    failureThreshold: 3
    initialDelaySeconds: 30
    periodSeconds: 10
    successThreshold: 1
    timeoutSeconds: 5
  networkPolicy:
    allowExternal: true
    allowExternalEgress: true
    enabled: true
    extraEgress: []
    extraIngress: []
    ingressNSMatchLabels: {}
    ingressNSPodMatchLabels: {}
  nodeAffinityPreset:
    key: ''
    type: ''
    values: []
  nodeSelector: {}
  pdb:
    create: false
    maxUnavailable: ''
    minAvailable: 1
  podAffinityPreset: ''
  podAnnotations: {}
  podAntiAffinityPreset: soft
  podLabels: {}
  podSecurityContext:
    enabled: true
    fsGroup: 1001
    fsGroupChangePolicy: Always
    supplementalGroups: []
    sysctls: []
  priorityClassName: ''
  readinessProbe:
    enabled: true
    failureThreshold: 6
    initialDelaySeconds: 0
    periodSeconds: 5
    successThreshold: 1
    timeoutSeconds: 5
  replicaCount: 1
  resources: {}
  resourcesPreset: nano
  schedulerName: ''
  serverBlockConfig: |-
    location /healthz {
      return 200;
    }

    location / {
      return 404;
    }
  service:
    annotations: {}
    ports:
      http: 80
    type: ClusterIP
  sidecars: []
  startupProbe:
    enabled: false
    failureThreshold: 6
    initialDelaySeconds: 0
    periodSeconds: 5
    successThreshold: 1
    timeoutSeconds: 5
  terminationGracePeriodSeconds: 60
  tolerations: []
  topologySpreadConstraints: []
defaultBackendService: ''
dhParam: ''
dnsConfig: {}
dnsPolicy: ClusterFirst
electionID: ingress-controller-leader
extraArgs: {}
extraDeploy: []
extraEnvVars: []
extraEnvVarsCM: ''
extraEnvVarsSecret: ''
extraVolumeMounts: []
extraVolumes: []
fullnameOverride: ''
global:
  compatibility:
    openshift:
      adaptSecurityContext: auto
  imagePullSecrets: []
  imageRegistry: ''
hostAliases: []
hostNetwork: false
image:
  digest: ''
  pullPolicy: IfNotPresent
  pullSecrets: []
  registry: registry.cn-hangzhou.aliyuncs.com
  repository: abroad_images/nginx-ingress-controller
  tag: 1.10.0-debian-12-r3
ingressClassResource:
  controllerClass: k8s.io/ingress-nginx
  default: false
  enabled: true
  name: nginx
  parameters: {}
initContainers: []
kind: Deployment
kubeVersion: ''
lifecycle: {}
lifecycleHooks: {}
livenessProbe:
  enabled: true
  failureThreshold: 3
  initialDelaySeconds: 10
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 1
maxmindLicenseKey: ''
metrics:
  enabled: false
  prometheusRule:
    additionalLabels: {}
    enabled: false
    namespace: ''
    rules: []
  service:
    annotations:
      prometheus.io/port: >-
        {{ coalesce .Values.metrics.service.ports.metrics
        .Values.metrics.service.port }}
      prometheus.io/scrape: 'true'
    labels: {}
    ports:
      metrics: 9913
    type: ClusterIP
  serviceMonitor:
    annotations: {}
    enabled: false
    honorLabels: false
    interval: 30s
    jobLabel: ''
    labels: {}
    metricRelabelings: []
    namespace: ''
    relabelings: []
    scrapeTimeout: ''
    selector: {}
minReadySeconds: 0
nameOverride: ''
namespaceOverride: ''
networkPolicy:
  allowExternal: true
  allowExternalEgress: true
  enabled: true
  extraEgress: []
  extraIngress: []
  ingressNSMatchLabels: {}
  ingressNSPodMatchLabels: {}
  kubeAPIServerPorts:
    - 443
    - 6443
    - 8443
nodeAffinityPreset:
  key: ''
  type: ''
  values: []
nodeSelector: {}
pdb:
  create: false
  maxUnavailable: ''
  minAvailable: 1
podAffinityPreset: ''
podAnnotations: {}
podAntiAffinityPreset: soft
podLabels: {}
podSecurityContext:
  enabled: true
  fsGroup: 1001
  fsGroupChangePolicy: Always
  supplementalGroups: []
  sysctls: []
podSecurityPolicy:
  enabled: false
priorityClassName: ''
proxySetHeaders: {}
publishService:
  enabled: false
  pathOverride: ''
rbac:
  create: true
  rules: []
readinessProbe:
  enabled: true
  failureThreshold: 3
  initialDelaySeconds: 10
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 1
replicaCount: 1
reportNodeInternalIp: false
resources: {}
resourcesPreset: nano
revisionHistoryLimit: 10
schedulerName: ''
scope:
  enabled: false
  namespace: ''
service:
  annotations: {}
  clusterIP: ''
  externalIPs: []
  externalTrafficPolicy: ''
  extraPorts: []
  healthCheckNodePort: 0
  ipFamilies: []
  ipFamilyPolicy: ''
  labels: {}
  loadBalancerIP: ''
  loadBalancerSourceRanges: []
  nodePorts:
    http: ''
    https: ''
    tcp: {}
    udp: {}
  ports:
    http: 80
    https: 443
  sessionAffinity: None
  sessionAffinityConfig: {}
  targetPorts:
    http: http
    https: https
  type: NodePort
serviceAccount:
  annotations: {}
  automountServiceAccountToken: false
  create: true
  name: ''
sidecars: []
startupProbe:
  enabled: false
  failureThreshold: 3
  initialDelaySeconds: 10
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 1
tcp: {}
tcpConfigMapNamespace: ''
terminationGracePeriodSeconds: 60
tolerations: []
topologySpreadConstraints: []
udp: {}
udpConfigMapNamespace: ''
updateStrategy: {}
watchIngressWithoutClass: false

6、点击【安装】

image-20250112193738494

7、点击【工作负载】-【Deployment】,观察到资源已成功建立

image-20250112194118455

后台查看

[root@rocky9-20 ~]# kubectl get po -n ingress-nginx
NAME                                                              READY   STATUS    RESTARTS   AGE
nginx-ingress-controller-11-1736681899-578d67f7f-jjfc8            1/1     Running   0          3m46s
nginx-ingress-controller-11-1736681899-default-backend-857sdllc   1/1     Running   0          3m46s