You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO: move yaml out of python code to resources/manifests/
91
+
#
92
+
# might not be worth it since we are just reading the yaml to then create a bunch of values and its not
93
+
# actually used to deploy anything into the cluster
94
+
# Then benefit would be making this code a bit cleaner and easy to follow, fwiw
95
+
kubeconfig_content=f"""apiVersion: v1
96
+
kind: Config
97
+
clusters:
98
+
- name: {cluster_name}
99
+
cluster:
100
+
server: {cluster_server}
101
+
certificate-authority-data: {cluster_ca}
102
+
users:
103
+
- name: {sa}
104
+
user:
105
+
token: {token}
106
+
contexts:
107
+
- name: {sa}-{namespace}
108
+
context:
109
+
cluster: {cluster_name}
110
+
namespace: {namespace}
111
+
user: {sa}
112
+
current-context: {sa}-{namespace}
113
+
"""
114
+
withopen(kubeconfig_file, "w") asf:
115
+
f.write(kubeconfig_content)
116
+
117
+
click.echo(f" Created kubeconfig file for {sa}: {kubeconfig_file}")
118
+
119
+
click.echo("---")
120
+
click.echo(
121
+
f"All kubeconfig files have been created in the '{kubeconfig_dir}' directory with a duration of {token_duration} seconds."
122
+
)
123
+
click.echo("Distribute these files to the respective users.")
124
+
click.echo(
125
+
"Users can then use by running `warnet auth <file>` or with kubectl by specifying the --kubeconfig flag or by setting the KUBECONFIG environment variable."
126
+
)
127
+
click.echo(f"Note: The tokens will expire after {token_duration} seconds.")
0 commit comments