|
|
Kubernetes Engine (GKE)
Author: Venkata Sudhakar
<p>Google Kubernetes Engine (GKE) is a managed Kubernetes service that lets you run containerized applications at scale. GKE handles cluster management, upgrades, and scaling so you can focus on deploying your applications.</p><p><b>Key Features:</b></p><p>1. <b>Autopilot mode</b> - Fully managed Kubernetes where Google manages node provisioning and configuration.</p><p>2. <b>Auto-scaling</b> - Horizontal Pod Autoscaler (HPA) and Cluster Autoscaler scale pods and nodes automatically.</p><p>3. <b>Auto-upgrade</b> - Automatically upgrades control plane and nodes to the latest stable Kubernetes version.</p><p>4. <b>Workload Identity</b> - Securely connect GKE workloads to GCP services using IAM without service account keys.</p><p>5. <b>Multi-cluster</b> - Manage multiple clusters across regions with Fleet management.</p><p>The below example shows how to create a GKE cluster and deploy an application.</p><textarea id="code" class="brush: bash">
# Create an Autopilot GKE cluster
gcloud container clusters create-auto my-cluster \
--region=us-central1
# Get credentials
gcloud container clusters get-credentials my-cluster \
--region=us-central1
# Check nodes
kubectl get nodes
</textarea>
<br/><p>Kubernetes deployment YAML,</p>
<textarea id="code" class="brush: bash">
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: gcr.io/my-project/my-app:v1
ports:
- containerPort: 8080
resources:
requests:
memory: "128Mi"
cpu: "250m"
---
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
</textarea>
<br/><p>It gives the following output,</p>
<pre class="output">
kubectl apply -f deployment.yaml
deployment.apps/my-app created
service/my-app-service created
kubectl get pods
NAME READY STATUS RESTARTS AGE
my-app-7d9-xk2p9 1/1 Running 0 30s
my-app-7d9-n8r4m 1/1 Running 0 30s
my-app-7d9-p2t7q 1/1 Running 0 30s
</pre>
<p><b>GKE Modes:</b></p><p><b>Standard mode</b> - Full control over node configuration, pay per node. Best for advanced Kubernetes users needing custom node configs.</p><p><b>Autopilot mode</b> - Google manages nodes, pay per pod. Best for teams wanting minimal cluster management overhead.</p>
|
|