【问题标题】:How to update worker nodes /etc/hosts file in GKE如何在 GKE 中更新工作节点 /etc/hosts 文件
【发布时间】:2019-05-30 22:30:03
【问题描述】:

我使用 terraform 脚本创建了一个 GKE 集群。我有一个必须更新 /etc/hosts 文件的情况。是否可以在使用 terraform 创建 K8 集群期间更新工作节点上的主机文件?

【问题讨论】:

    标签: google-cloud-platform google-compute-engine terraform google-kubernetes-engine


    【解决方案1】:

    使用 terraform 无法访问该目录,您可以使用带有 Security Context 的DeamonSet,如下所示:

    kind: DaemonSet
    apiVersion: extensions/v1beta1
    metadata:
      name: ssd-startup-script
      labels:
        app: ssd-startup-script
    spec:
      template:
        metadata:
          labels:
            app: ssd-startup-script
        spec:
          hostPID: true
          containers:
          - name: ssd-startup-script
            image: gcr.io/google-containers/startup-script:v1
            imagePullPolicy: Always
            securityContext:
              privileged: true
            env:
            - name: STARTUP_SCRIPT
              value: |
                #!/bin/bash
                <YOUR COMMAND LINE>
                <YOUR COMMAND LINE>
                <YOUR COMMAND LINE>
                echo Done
    

    您需要运行kubectl apply -f &lt;demonset yaml file&gt;

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多