k8s修改pod的hosts文件
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。
--------崔帅的拾荒