Created
September 26, 2022 06:39
-
-
Save yuswitayudi/98eaeb2b9a6077868bc96159a2d998f6 to your computer and use it in GitHub Desktop.
File ini untuk membuat certificate, private key, role dan rolebinding untuk keperluan membuat user pada kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in yuswitayudi | |
do | |
openssl genrsa -out $i.key 2048 | |
openssl req -new -key $i.key -out $i.csr -subj "/CN=$i/O=finance" | |
openssl x509 -req -in $i.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $i.crt -days 365 | |
kubectl --kubeconfig $i.config config set-cluster kubernetes-dev --server https://192.168.1.223:6443 --certificate-authority=ca.crt | |
kubectl --kubeconfig $i.config config set-credentials $i --client-certificate $i.crt --client-key $i.key | |
kubectl --kubeconfig $i.config config set-context $i-dev --cluster kubernetes-dev --namespace dev --user=$i | |
kubectl --kubeconfig $i.config config use-context $i-dev | |
kubectl create role $i-dev --verb=* --resource=*.* --namespace dev | |
kubectl create rolebinding $i-dev-rolebinding --role=$i-dev --user $i --namespace=dev | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment