Skip to content

Commit 063bc93

Browse files
committed
fix: SSM become_user 권한 에러 수정 — --kubeconfig 플래그로 대체
SSM 연결에서 become_user: ubuntu 사용 시 임시 파일 권한 설정 실패. 모든 kubectl/helm 명령에 --kubeconfig=/home/ubuntu/.kube/config 플래그 추가.
1 parent 42d7bb4 commit 063bc93

5 files changed

Lines changed: 22 additions & 24 deletions

File tree

IaC/3-v3/ansible/roles/calico/tasks/main.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
# ============================================================
55

66
- name: Install Tigera Operator
7-
become_user: ubuntu
87
command: >
9-
kubectl create -f
8+
kubectl --kubeconfig=/home/ubuntu/.kube/config create -f
109
https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/tigera-operator.yaml
1110
register: tigera_result
1211
failed_when: tigera_result.rc != 0 and 'already exists' not in tigera_result.stderr
1312
changed_when: "'created' in tigera_result.stdout"
1413

1514
- name: Apply Calico custom resource
16-
become_user: ubuntu
1715
copy:
1816
content: |
1917
apiVersion: operator.tigera.io/v1
@@ -30,13 +28,14 @@
3028
dest: /tmp/calico-installation.yaml
3129

3230
- name: Apply Calico installation
33-
become_user: ubuntu
34-
command: kubectl apply -f /tmp/calico-installation.yaml
31+
command: >
32+
kubectl --kubeconfig=/home/ubuntu/.kube/config
33+
apply -f /tmp/calico-installation.yaml
3534
3635
- name: Wait for Calico pods to be ready
37-
become_user: ubuntu
3836
command: >
39-
kubectl wait --for=condition=Ready pods
37+
kubectl --kubeconfig=/home/ubuntu/.kube/config
38+
wait --for=condition=Ready pods
4039
--all -n calico-system
4140
--timeout=300s
4241
retries: 3

IaC/3-v3/ansible/roles/ebs-csi/tasks/main.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# ============================================================
55

66
- name: Deploy EBS CSI Driver
7-
become_user: ubuntu
87
command: >
9-
kubectl apply -k
8+
kubectl --kubeconfig=/home/ubuntu/.kube/config apply -k
109
"github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/?ref=release-1.37"
1110
register: ebs_csi_result
1211
changed_when: "'created' in ebs_csi_result.stdout or 'configured' in ebs_csi_result.stdout"
1312

1413
- name: Create gp3 StorageClass
15-
become_user: ubuntu
1614
copy:
1715
content: |
1816
apiVersion: storage.k8s.io/v1
@@ -29,5 +27,6 @@
2927
dest: /tmp/storageclass-gp3.yaml
3028

3129
- name: Apply StorageClass
32-
become_user: ubuntu
33-
command: kubectl apply -f /tmp/storageclass-gp3.yaml
30+
command: >
31+
kubectl --kubeconfig=/home/ubuntu/.kube/config
32+
apply -f /tmp/storageclass-gp3.yaml

IaC/3-v3/ansible/roles/gateway-fabric/tasks/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
# ============================================================
55

66
- name: Install Gateway API CRDs
7-
become_user: ubuntu
87
command: >
9-
kubectl apply -f
8+
kubectl --kubeconfig=/home/ubuntu/.kube/config apply -f
109
https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml
1110
register: gateway_api_result
1211
changed_when: "'created' in gateway_api_result.stdout"
1312

1413
- name: Add NGINX Gateway Fabric Helm repo
15-
become_user: ubuntu
16-
command: helm repo add nginx-gateway https://kubernetes-sigs.github.io/nginx-gateway-fabric
14+
command: >
15+
helm --kubeconfig=/home/ubuntu/.kube/config
16+
repo add nginx-gateway https://kubernetes-sigs.github.io/nginx-gateway-fabric
1717
register: helm_repo
1818
failed_when: helm_repo.rc != 0 and 'already exists' not in helm_repo.stderr
1919
changed_when: "'added' in helm_repo.stdout"
2020

2121
- name: Update Helm repos
22-
become_user: ubuntu
23-
command: helm repo update
22+
command: >
23+
helm --kubeconfig=/home/ubuntu/.kube/config repo update
2424
2525
- name: Install NGINX Gateway Fabric
26-
become_user: ubuntu
2726
command: >
28-
helm upgrade --install nginx-gateway nginx-gateway/nginx-gateway-fabric
27+
helm --kubeconfig=/home/ubuntu/.kube/config
28+
upgrade --install nginx-gateway nginx-gateway/nginx-gateway-fabric
2929
--namespace nginx-gateway --create-namespace
3030
--set service.type=NodePort
3131
--set service.ports[0].port=80,service.ports[0].nodePort={{ gateway_nodeport_http }}

IaC/3-v3/ansible/roles/kubeadm-init/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252

5353
- name: Label CP node
5454
command: >
55-
kubectl label node {{ inventory_hostname }}
55+
kubectl --kubeconfig=/home/ubuntu/.kube/config
56+
label node {{ inventory_hostname }}
5657
node-role.kubernetes.io/control-plane=
5758
--overwrite
58-
become_user: ubuntu
5959
changed_when: false

IaC/3-v3/ansible/roles/kubeadm-join/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
- name: Label worker node (from CP)
1616
delegate_to: "{{ groups['role_control_plane'][0] }}"
17-
become_user: ubuntu
1817
command: >
19-
kubectl label node {{ inventory_hostname }}
18+
kubectl --kubeconfig=/home/ubuntu/.kube/config
19+
label node {{ inventory_hostname }}
2020
node-role.kubernetes.io/worker=
2121
dojangkok.cloud/nodepool={{ k8s_nodepool | default('default') }}
2222
topology.kubernetes.io/zone={{ node_az }}

0 commit comments

Comments
 (0)