Bash 如何使用Jina模板创建GKE私有集群?

Bash 如何使用Jina模板创建GKE私有集群?,bash,google-cloud-platform,jinja2,google-kubernetes-engine,gke-networking,Bash,Google Cloud Platform,Jinja2,Google Kubernetes Engine,Gke Networking,我正试图编写一个Jinja模板和一个bash脚本来创建一个私有GKE集群,其中有一个选项(在我的bash脚本中)来允许它访问私有和公共端点 因此,我希望我的bash脚本在默认情况下使这个集群具有私有端点访问权限,并在用户运行时使用标志(deployment.sh--public endpoint)使其具有公共端点访问权限 这就是我的jinja模板的外观: resources: - name: {{ CLUSTER_NAME }} type: container.v1.cluster pr

我正试图编写一个Jinja模板和一个bash脚本来创建一个私有GKE集群,其中有一个选项(在我的bash脚本中)来允许它访问私有和公共端点

因此,我希望我的bash脚本在默认情况下使这个集群具有私有端点访问权限,并在用户运行时使用标志(deployment.sh--public endpoint)使其具有公共端点访问权限

这就是我的jinja模板的外观:

resources:
- name: {{ CLUSTER_NAME }}
  type: container.v1.cluster
  properties:
    zone: {{ properties["zone"] }}
    cluster:
      name: {{ CLUSTER_NAME }}
      description: Customer Stack Cluster 
      network: {{properties["network"]}}
      subnetwork: {{properties["subnetwork"]}}
      *privateClusterConfig:
        enablePrivateNodes: true
        enablePrivateEndpoint: true
        **{% if --public-endpoint flag was passed %}
             <p> Make it with a public endpoint access </p>
        {% else %}
             <p> make it with private endpoint access </p>
        {% endif %}***
        # Configure the IP range for the hosted master network
        masterIpv4CidrBlock: 172.16.0.32/28
      ipAllocationPolicy:
        useIpAliases: true
      nodePools: 
        - name: nodepool
          config: 
            oauthScopes:
            - https://www.googleapis.com/auth/compute
            - https://www.googleapis.com/auth/logging.write
            - https://www.googleapis.com/auth/monitoring
            - https://www.googleapis.com/auth/devstorage.full_control
            machineType: n1-standard-2
            # Default will be passed in 
            serviceAccount: {{ properties['computeServiceAccount'] }}
          autoscaling: 
            enabled: true 
            minNodeCount: 2
            maxNodeCount: 5
          initialNodeCount: 2
我不知道如何实现这一点,也不知道if语句synax在jinja中是如何实现的


任何帮助都将不胜感激

如果您想为某些专用节点提供出站internet访问,可以使用云NAT或管理您自己的NAT网关。请检查,以便在两个不同的文件中分离不同的部署更有意义,因为在使用公共端点的情况下,您可能还必须设置云NAT或自己的NAT网关。“因为在使用公共端点的情况下,您可能还必须设置云NAT或自己的NAT网关”-您是指私有端点?
CLUSTER=$(gcloud deployment-manager deployments create "${NAME}" --template deployment.jinja --properties "region:${REGION},zone:${ZONE},network:${NETWORK},subnetwork:${SUBNETWORK},computeServiceAccount:${COMPUTE_SA},k8sVersion:\"${K8S_VERSION}\"" --format=json)
if [ $? -ne 0 ]; then error "FAILED_DEPLOY_GKE"; fi