Exercise 5.1: Configuring TLS Access
CP 노드에 연결된 터미널로 이동
kubeconfig 파일 리뷰
cat $HOME/.kube/config
인증서들을 파일로 저장
{ export client=$(grep client-cert $HOME/.kube/config |cut -d" " -f 6) echo $client | base64 -d - > ./client.pem export key=$(grep client-key-data $HOME/.kube/config |cut -d " " -f 6) echo $key | base64 -d - > ./client-key.pem export ca=$(grep certificate-authority-data $HOME/.kube/config |cut -d " " -f 6) echo $ca | base64 -d - > ./ca.pem }
API 서버 주소 확인
kubectl config view | grep server
Pod 목록을 보는 API 호출 - https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/
curl https://k8scp:6443/api/v1/pods \ --cert ./client.pem --key ./client-key.pem --cacert ./ca.pem
JSON 형식의 Pod Manifest 파일 생성
cat << EOF > nginx.json { "kind": "Pod", "apiVersion": "v1", "metadata":{ "name": "nginx", "namespace": "default", "labels": { "app": "nginx" } }, "spec": { "containers": [{ "name": "nginx", "image": "nginx", "ports": [{"containerPort": 80}] }] } } EOF
위에서 생성한 Manifest 파일로 API 호출을 통해서 Pod 생성
curl https://k8scp:6443/api/v1/namespaces/default/pods \ -XPOST -H'Content-Type: application/json' [email protected] \ --cert ./client.pem --key ./client-key.pem --cacert ./ca.pem
Pod가 정상적으로 생성됐는지 확인
kubectl get pod nginx
Last updated