title | description |
---|---|
GCP Google Kubernetes Engine - Create GKE Cluster |
Learn to create Google Kubernetes Engine GKE Cluster |
- Create GKE Standard GKE Cluster
- Configure Google CloudShell to access GKE Cluster
- Deploy simple Kubernetes Deployment and Kubernetes Load Balancer Service and Test
- Clean-Up
- Go to Kubernetes Engine -> Clusters -> CREATE
- Select GKE Standard -> CONFIGURE
- Cluster Basics
- Name: standard-public-cluster-1
- Location type: Regional
- Region: us-central1
- Specify default node locations: us-central1-a, us-central1-b, us-central1-c
- Release Channel
- Release Channel: Rapid Channel
- Version: LATEST AVAIALABLE ON THAT DAY
- REST ALL LEAVE TO DEFAULTS
- NODE POOLS: default-pool
- Node pool details
- Name: default-pool
- Number of Nodes (per zone): 1
- Node Pool Upgrade Strategy: Surge Upgrade
- Nodes: Configure node settings
- Image type: Containerized Optimized OS
- Machine configuration
- GENERAL PURPOSE SERIES: E2
- Machine Type: e2-small
- Boot disk type: Balanced persistent disk
- Boot disk size(GB): 20
- Boot disk encryption: Google-managed encryption key (default )
- Enable Node on Spot VMs: CHECKED
- Node Networking: LEAVE TO DEFAULTS
- Node Security:
- Access scopes: Allow default access (LEAVE TO DEFAULT)
- REST ALL REVIEW AND LEAVE TO DEFAULTS
- Node Metadata: REVIEW AND LEAVE TO DEFAULTS
- CLUSTER
- Automation: REVIEW AND LEAVE TO DEFAULTS
- Networking: REVIEW AND LEAVE TO DEFAULTS
- CHECK THIS BOX: Enable Dataplane V2 CHECK IT - IN FUTURE VERSIONS IT WILL BE BY DEFAULT ENABLED
- Security: REVIEW AND LEAVE TO DEFAULTS
- CHECK THIS BOX: Enable Workload Identity CHECK IT - IN FUTURE VERSIONS IT WILL BE BY DEFAULT ENABLED
- Metadata: REVIEW AND LEAVE TO DEFAULTS
- Features: REVIEW AND LEAVE TO DEFAULTS
- CLICK ON CREATE
- Go to Kubernetes Engine -> Clusters -> standard-public-cluster-1
- Review
- Details Tab
- Nodes Tab
- Review same nodes Compute Engine
- Storage Tab
- Review Storage Classes
- Logs Tab
- Review Cluster Logs
- Review Cluster Logs Filter By Severity
- Go to Kubernetes Engine -> Clusters -> standard-public-cluster-1
- Workloads -> SHOW SYSTEM WORKLOADS
- Go to Kubernetes Engine -> Clusters -> standard-public-cluster-1
- Services & Ingress -> SHOW SYSTEM OBJECTS
- Go to Kubernetes Engine -> Clusters -> standard-public-cluster-1
- Applications
- Secrets & ConfigMaps
- Go to Kubernetes Engine -> Clusters -> standard-public-cluster-1
- Storage Classes
- premium-rwo
- standard
- standard-rwo
- Object Browser
- Migrate to Containers
- Backup for GKE
- Config Management
- Protect
# Verify gke-gcloud-auth-plugin Installation (if not installed, install it)
gke-gcloud-auth-plugin --version
# Install Kubectl authentication plugin for GKE
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
# Verify gke-gcloud-auth-plugin Installation
gke-gcloud-auth-plugin --version
# Configure kubeconfig for kubectl
gcloud container clusters get-credentials <CLUSTER-NAME> --region <REGION> --project <PROJECT-NAME>
gcloud container clusters get-credentials standard-public-cluster-1 --region us-central1 --project kdaida123
# Run kubectl with the new plugin prior to the release of v1.25
vi ~/.bashrc
USE_GKE_GCLOUD_AUTH_PLUGIN=True
# Reload the environment value
source ~/.bashrc
# Check if Environment variable loaded in Terminal
echo $USE_GKE_GCLOUD_AUTH_PLUGIN
# Verify kubectl version
kubectl version --short
# Install kubectl (if not installed)
gcloud components install kubectl
# Configure kubectl
gcloud container clusters get-credentials <CLUSTER-NAME> --zone <ZONE> --project <PROJECT-ID>
gcloud container clusters get-credentials standard-cluster-1 --zone us-central1-c --project kdaida123
# Verify Kubernetes Worker Nodes
kubectl get nodes
# Verify System Pod in kube-system Namespace
kubectl -n kube-system get pods
# Verify kubeconfig file
cat $HOME/.kube/config
kubectl config view
- Folder: kube-manifests
apiVersion: apps/v1
kind: Deployment
metadata: #Dictionary
name: myapp1-deployment
spec: # Dictionary
replicas: 2
selector:
matchLabels:
app: myapp1
template:
metadata: # Dictionary
name: myapp1-pod
labels: # Dictionary
app: myapp1 # Key value pairs
spec:
containers: # List
- name: myapp1-container
image: stacksimplify/kubenginx:1.0.0
ports:
- containerPort: 80
- Folder: kube-manifests
apiVersion: v1
kind: Service
metadata:
name: myapp1-lb-service
spec:
type: LoadBalancer # ClusterIp, # NodePort
selector:
app: myapp1
ports:
- name: http
port: 80 # Service Port
targetPort: 80 # Container Port
# Upload Sample App to Google CloudShell
Go to Google CloudShell -> 3 Dots -> Upload -> Folder -> google-kubernetes-engine
# Change Directory
cd google-kubernetes-engine/02-Create-GKE-Cluster
# Verify folder uploaded
ls kube-manifests/
# Verify Files
cat kube-manifests/01-kubernetes-deployment.yaml
cat kube-manifests/02-kubernetes-loadbalancer-service.yaml
# Change Directory
cd google-kubernetes-engine/02-Create-GKE-Cluster
# Deploy Sample App using kubectl
kubectl apply -f kube-manifests/
# List Deployments
kubectl get deploy
# List Pods
kubectl get pod
# List Services
kubectl get svc
# Access Sample Application
http://<EXTERNAL-IP>
- Go to GCP Console -> Kubernetes Engine -> Workloads
- Click on myapp1-deployment
- Review all tabs
- Go to GCP Console -> Kubernetes Engine -> Services & Ingress
- Click on myapp1-lb-service
- Review all tabs
- Go to GCP Console -> Networking Services -> Load Balancing
- Review all tabs
- Go to Google Cloud Shell
# Change Directory
cd google-kubernetes-engine/02-Create-GKE-Cluster
# Delete Kubernetes Deployment and Service
kubectl delete -f kube-manifests/
# List Deployments
kubectl get deploy
# List Pods
kubectl get pod
# List Services
kubectl get svc