Skip to content

Commit 6ec30f9

Browse files
committed
Security fix: Replace hardcoded kubeconfig with KUBE_CONFIG secret
1 parent 1c29dc8 commit 6ec30f9

File tree

6 files changed

+24
-132
lines changed

6 files changed

+24
-132
lines changed

.github/workflows/deploy-auth-service.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,14 @@ jobs:
8686
helm version
8787
8888
- name: Configure kubectl
89+
env:
90+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
8991
run: |
9092
echo "🔧 Configuring kubectl..."
9193
92-
# Set up kubectl configuration
94+
# Set up kubectl configuration from secret
9395
mkdir -p $HOME/.kube
94-
cat > $HOME/.kube/config << 'EOF'
95-
apiVersion: v1
96-
kind: Config
97-
clusters:
98-
- name: "student"
99-
cluster:
100-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
101-
102-
users:
103-
- name: "student"
104-
user:
105-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
106-
107-
contexts:
108-
- name: "student"
109-
context:
110-
user: "student"
111-
cluster: "student"
112-
113-
current-context: "student"
114-
EOF
96+
echo "$KUBE_CONFIG" > $HOME/.kube/config
11597
chmod 600 $HOME/.kube/config
11698
11799
echo "✅ Kubectl configured"

.github/workflows/deploy-client.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,14 @@ jobs:
8888
helm version
8989
9090
- name: Configure kubectl
91+
env:
92+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
9193
run: |
9294
echo "🔧 Configuring kubectl..."
9395
94-
# Set up kubectl configuration
96+
# Set up kubectl configuration from secret
9597
mkdir -p $HOME/.kube
96-
cat > $HOME/.kube/config << 'EOF'
97-
apiVersion: v1
98-
kind: Config
99-
clusters:
100-
- name: "student"
101-
cluster:
102-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
103-
104-
users:
105-
- name: "student"
106-
user:
107-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
108-
109-
contexts:
110-
- name: "student"
111-
context:
112-
user: "student"
113-
cluster: "student"
114-
115-
current-context: "student"
116-
EOF
98+
echo "$KUBE_CONFIG" > $HOME/.kube/config
11799
chmod 600 $HOME/.kube/config
118100
119101
echo "✅ Kubectl configured"

.github/workflows/deploy-document-service.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,14 @@ jobs:
8686
helm version
8787
8888
- name: Configure kubectl
89+
env:
90+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
8991
run: |
9092
echo "🔧 Configuring kubectl..."
9193
92-
# Set up kubectl configuration
94+
# Set up kubectl configuration from secret
9395
mkdir -p $HOME/.kube
94-
cat > $HOME/.kube/config << 'EOF'
95-
apiVersion: v1
96-
kind: Config
97-
clusters:
98-
- name: "student"
99-
cluster:
100-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
101-
102-
users:
103-
- name: "student"
104-
user:
105-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
106-
107-
contexts:
108-
- name: "student"
109-
context:
110-
user: "student"
111-
cluster: "student"
112-
113-
current-context: "student"
114-
EOF
96+
echo "$KUBE_CONFIG" > $HOME/.kube/config
11597
chmod 600 $HOME/.kube/config
11698
11799
echo "✅ Kubectl configured"

.github/workflows/deploy-genai-backend.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,14 @@ jobs:
8888
helm version
8989
9090
- name: Configure kubectl
91+
env:
92+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
9193
run: |
9294
echo "🔧 Configuring kubectl..."
9395
94-
# Set up kubectl configuration
96+
# Set up kubectl configuration from secret
9597
mkdir -p $HOME/.kube
96-
cat > $HOME/.kube/config << 'EOF'
97-
apiVersion: v1
98-
kind: Config
99-
clusters:
100-
- name: "student"
101-
cluster:
102-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
103-
104-
users:
105-
- name: "student"
106-
user:
107-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
108-
109-
contexts:
110-
- name: "student"
111-
context:
112-
user: "student"
113-
cluster: "student"
114-
115-
current-context: "student"
116-
EOF
98+
echo "$KUBE_CONFIG" > $HOME/.kube/config
11799
chmod 600 $HOME/.kube/config
118100
119101
echo "✅ Kubectl configured"

.github/workflows/deploy-genai-service.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,14 @@ jobs:
8686
helm version
8787
8888
- name: Configure kubectl
89+
env:
90+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
8991
run: |
9092
echo "🔧 Configuring kubectl..."
9193
92-
# Set up kubectl configuration
94+
# Set up kubectl configuration from secret
9395
mkdir -p $HOME/.kube
94-
cat > $HOME/.kube/config << 'EOF'
95-
apiVersion: v1
96-
kind: Config
97-
clusters:
98-
- name: "student"
99-
cluster:
100-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
101-
102-
users:
103-
- name: "student"
104-
user:
105-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
106-
107-
contexts:
108-
- name: "student"
109-
context:
110-
user: "student"
111-
cluster: "student"
112-
113-
current-context: "student"
114-
EOF
96+
echo "$KUBE_CONFIG" > $HOME/.kube/config
11597
chmod 600 $HOME/.kube/config
11698
11799
echo "✅ Kubectl configured"

.github/workflows/deploy-infrastructure.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,14 @@ jobs:
5252
helm version
5353
5454
- name: Configure kubectl
55+
env:
56+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
5557
run: |
5658
echo "🔧 Configuring kubectl..."
5759
58-
# Set up kubectl configuration
60+
# Set up kubectl configuration from secret
5961
mkdir -p $HOME/.kube
60-
cat > $HOME/.kube/config << 'EOF'
61-
apiVersion: v1
62-
kind: Config
63-
clusters:
64-
- name: "student"
65-
cluster:
66-
server: "https://rancher.ase.cit.tum.de/k8s/clusters/c-m-nhcfjg9h"
67-
68-
users:
69-
- name: "student"
70-
user:
71-
token: "kubeconfig-u-g7fbq4tzcsrjvb2:dtw5qr2nkwl5hl4r676dlmt7v9lh9bw5xgkp5l65pf6tr6ql79zsmm"
72-
73-
contexts:
74-
- name: "student"
75-
context:
76-
user: "student"
77-
cluster: "student"
78-
79-
current-context: "student"
80-
EOF
62+
echo "$KUBE_CONFIG" > $HOME/.kube/config
8163
chmod 600 $HOME/.kube/config
8264
8365
echo "✅ Kubectl configured"

0 commit comments

Comments
 (0)