Zor Yoldan Kubernetes Kurulumu— 14 (Kubectl’in Uzak Bağlantı İçin Ayarlanması)

Murat Çabuk
2 min readDec 25, 2021

Öncelikle Kubernetes API’sine host makinamızda oluşturmuş olduğumuz CA sertifikası ile ulaşıp ulaşmadığımızı test ediyoruz.

İlk bölümde kurmuş olduğumuz HaProxy Load Balancer’ımızı kontrol etmek için host makinamızda ~/kubernetes dizininde olan ca.pem CA sertifikamızı kullanıyoruz.

curl --cacert ca.pem https://10.240.10.10:6443/version
{
"major": "1",
"minor": "21",
"gitVersion": "v1.21.0",
"gitCommit": "cb303e613a121a29364f75cc67d3d580833a7479",
"gitTreeState": "clean",
"buildDate": "2021-04-08T16:25:06Z",
"goVersion": "go1.16.1",
"compiler": "gc",
"platform": "linux/amd64"
}

Öncelikle kubectl için konfigürasyon ve sertifika ayarlarını yapıyoruz.

Linux ve Mac için

cd ~/kubernetes

KUBERNETES_PUBLIC_ADDRESS=10.240.10.10

kubectl config set-cluster kubernetes-the-hard-way \
--certificate-authority=ca.pem \
--embed-certs=true \
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443

kubectl config set-credentials admin \
--client-certificate=admin.pem \
--client-key=admin-key.pem

kubectl config set-context kubernetes-the-hard-way \
--cluster=kubernetes-the-hard-way \
--user=admin

kubectl config use-context kubernetes-the-hard-way

Windows için

cd ~/kubernetes

$KUBERNETES_PUBLIC_ADDRESS=10.240.10.10

kubectl config set-cluster kubernetes-the-hard-way `
--certificate-authority="ca.pem" `
--embed-certs="true" `
--server=https://$KUBERNETES_PUBLIC_ADDRESS":6443"

kubectl config set-credentials admin `
--client-certificate="admin.pem" `
--client-key="admin-key.pem"

kubectl config set-context kubernetes-the-hard-way `
--cluster="kubernetes-the-hard-way" `
--user="admin"

kubectl config use-context kubernetes-the-hard-way

Daha sonra kubectl komutun test ediyoruz. Aşağıdaki gibi bir sonuç görmeliyiz.

kubectl version

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:25:06Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}

Aynı şekilde aşağıdaki komut da çalışmalı

kubectl get nodes

# sonuç

NAME STATUS ROLES AGE VERSION
worker-01 Ready <none> 11h v1.21.0
worker-02 Ready <none> 11h v1.21.0
worker-03 Ready <none> 11h v1.21.0

Originally published at https://github.com.

--

--