This commit is contained in:
parent
f22d7423e8
commit
fd31ce7eed
1 changed files with 30 additions and 0 deletions
30
generate_kubeconfig.sh
Normal file
30
generate_kubeconfig.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Erstellt ein Token
|
||||
TOKEN=$(kubectl -n kube-system create token haproxy-sa)
|
||||
|
||||
# Get Cluster Info
|
||||
CLUSTER_NAME=$(kubectl config view -o jsonpath='{.clusters[0].name}')
|
||||
CLUSTER_SERVER=$(kubectl config view -o jsonpath="{.clusters[0].cluster.server}")
|
||||
CA_DATA=$(kubectl config view --raw -o jsonpath="{.clusters[0].cluster.certificate-authority-data}")
|
||||
|
||||
# Erstelle kubeconfig
|
||||
cat <<EOF > haproxy-kubeconfig.yaml
|
||||
apiVersion: v1
|
||||
kind: Config
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: ${CA_DATA}
|
||||
server: ${CLUSTER_SERVER}
|
||||
name: ${CLUSTER_NAME}
|
||||
contexts:
|
||||
- context:
|
||||
cluster: ${CLUSTER_NAME}
|
||||
user: haproxy-sa
|
||||
name: haproxy-context
|
||||
current-context: haproxy-context
|
||||
users:
|
||||
- name: haproxy-sa
|
||||
user:
|
||||
token: ${TOKEN}
|
||||
EOF
|
Loading…
Add table
Reference in a new issue