Sunday, February 5, 2023
GCP Juara GCP Kubernetes

Orchestrating the Cloud with Kubernetes

cloud

“Orchestrating the Cloud with Kubernetes”

Pengantar

Kubernetes adalah proyek sumber terbuka (tersedia di kubernetes.io) yang dapat berjalan di berbagai lingkungan, mulai dari laptop hingga kluster multi-node dengan ketersediaan tinggi, dari cloud publik hingga penerapan di lokasi, dari mesin virtual hingga bare metal.

Praktikum

Google Kubernetes Engine

gcloud config set compute/zone us-central1-b
gcloud container clusters create io

Task 1. Get the sample code

gsutil cp -r gs://spls/gsp021/* .

cd orchestrate-with-kubernetes/kubernetes

Task 2. Quick Kubernetes Demo

kubectl create deployment nginx --image=nginx:1.10.0
  • Cek pod
kubectl get pods
  • expose keluar
kubectl expose deployment nginx --port 80 --type LoadBalancer
  • cek list service
kubectl get services
curl http://<External IP>:80

Task 3. Pods

Task 4. Creating pods

  • Masuk ke folder
cd ~/orchestrate-with-kubernetes/kubernetes
cat pods/monolith.yaml
  • Create monolith pod
kubectl create -f pods/monolith.yaml
kubectl get pods
kubectl describe pods monolith

Task 5. Interacting with pods

kubectl port-forward monolith 10080:80
curl http://127.0.0.1:10080
curl http://127.0.0.1:10080/secure
curl -u user http://127.0.0.1:10080/login
TOKEN=$(curl http://127.0.0.1:10080/login -u user|jq -r '.token')
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:10080/secure
  • Cek log dari terminal 3
kubectl logs monolith
kubectl logs -f monolith
  • masuk ke pod
kubectl exec monolith --stdin --tty -c monolith -- /bin/sh
ping -c 3 google.com
exit

Task 6. Services

Task 7. Creating a service

  • Masuk ke folder
cd ~/orchestrate-with-kubernetes/kubernetes
cat pods/secure-monolith.yaml


kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf
kubectl create -f pods/secure-monolith.yaml

cat services/monolith.yaml

kubectl create -f services/monolith.yaml

Task 8. Adding labels to pods

kubectl get pods -l "app=monolith"
kubectl get pods -l "app=monolith,secure=enabled"
kubectl label pods secure-monolith 'secure=enabled'
kubectl get pods secure-monolith --show-labels
kubectl describe services monolith | grep Endpoints
gcloud compute instances list
curl -k https://<EXTERNAL_IP>:31000

Task 9. Deploying applications with Kubernetes

Task 10. Creating deployments

kubectl create -f deployments/auth.yaml
kubectl create -f services/auth.yaml

kubectl create -f deployments/hello.yaml
kubectl create -f services/hello.yaml

kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml

kubectl get services frontend

curl -k https://<EXTERNAL-IP>

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Orchestrating the Cloud with Kubernetes. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 29 times, 1 visits today)
Baca Juga :  Build and Secure Networks in Google Cloud: Challenge Lab

Similar Posts