1、在1.7版本后使用HostAliases修改pod的hosts文件。该文件由kubelet管理

在deployment的yaml文件中添加在pod template 的spec里面即可:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
     app: runner
  name: gitlab-runner-gitlab-runner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: runner
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: runner
    spec:
      dnsPolicy: None
      dnsConfig:
        nameservers:
          - 10.3.9.13
          - 10.3.9.11
        searches:
          - gitlab.klog.com
          - reg.klog.com
        options:
          - name: ndots
            value: "2"
          - name: edns0
      hostAliases:
      - hostnames:
        - gitlab.klog.com
        ip: 10.3.2.13
      - hostnames:
        - reg.klog.com
        ip: 10.3.2.11
      imagePullSecrets:
      - name: registry-secrete

 

nameservers:是自己的内网dns

禁止访问外网,走hostaliases。 

相关文章:

  • 2022-12-23
  • 2021-06-16
  • 2021-12-08
  • 2021-09-05
  • 2022-01-06
  • 2022-02-08
猜你喜欢
  • 2022-02-16
  • 2022-12-23
  • 2021-06-18
  • 2021-05-19
相关资源
相似解决方案