billions-glass-17089
02/03/2022, 6:06 PMkubectl
?prehistoric-activity-61023
02/03/2022, 6:23 PMbillions-glass-17089
02/03/2022, 6:24 PMCluster
that might relate is masterAuth
prehistoric-activity-61023
02/03/2022, 6:25 PMGKE_KUBECONFIG_TEMPLATE = """
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: {0}
server: https://{1}
name: {2}
contexts:
- context:
cluster: {2}
user: {2}
name: {2}
current-context: {2}
kind: Config
preferences: {{}}
users:
- name: {2}
user:
auth-provider:
config:
cmd-args: config config-helper --format=json
cmd-path: gcloud
expiry-key: '{{.credential.token_expiry}}'
token-key: '{{.credential.access_token}}'
name: gcp
"""
self.cluster
in this context is an instance of `gcp.container.Cluster`:
#
# Generate kubeconfig
#
k8s_info = pulumi.Output.all(
self.cluster.name, # 0
self.cluster.endpoint, # 1
self.cluster.master_auth, # 2
self.cluster.project, # 3
self.cluster.location, # 4
)
self.kubeconfig = k8s_info.apply(
lambda info: GKE_KUBECONFIG_TEMPLATE.format(
info[2]["cluster_ca_certificate"],
info[1],
"{0}_{1}_{2}".format(info[3], info[4], info[0]),
)
)
k8s_provider = k8s.Provider(
"k8s-provider",
=> kubeconfig=kubeconfig,
)
billions-glass-17089
02/03/2022, 6:27 PMprehistoric-activity-61023
02/03/2022, 6:28 PMpulumi.ResourceOptions
and provider
optionbillions-glass-17089
02/03/2022, 6:44 PMfunction kubeConfigTemplate(
clusterName: Output<string>,
endpoint: Output<string>,
clusterCaCert: Output<string>
) {
return pulumi.interpolate`
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${clusterCaCert}
server: https://${endpoint}
name: ${clusterName}
contexts:
- context:
cluster: ${clusterName}
user: ${clusterName}
name: ${clusterName}
current-context: ${clusterName}
kind: Config
preferences: {}
users:
- name: ${clusterName}
user:
auth-provider:
config:
cmd-args: config config-helper --format=json
cmd-path: gcloud
expiry-key: '{.credential.token_expiry}'
token-key: '{.credential.access_token}'
name: gcp
`;
}
Thank you @prehistoric-activity-61023 for the help!