GCP - Kubernetes study notes
This is my study notes on playing around with GCP and Kubernetes. Not finished. Will be updated from time to time.
Setup
Enable k8s services (Google Kubernetes Engine API) in the console.
gcloud config set account my-google-account
gcloud container clusters create k0 --zone=asia-east1-a
For --zone
options you can select from here, a mistake I made was picking the region
grid instead of zone
grid. That will lead to errors.
Pods, Deployment and Services
A pod is a set of interconnected containers, somewhat similar to a docker-compose object.
# Launch a single instance:
kubectl run nginx --image=nginx:1.10.0
# Get pods
kubectl get pods
# Expose nginx
A deployement will automatically recreate the service if it was down due to some reasons. If you try to delete a pod that is in a deployment, it will "resurrected" automatically. see here
kubectl expose deployment nginx --port 80 --type LoadBalancer
# List services
kubectl get services
monolith.yaml
apiVersion: v1
kind: Pod
metadata:
name: monolith
labels:
app: monolith
spec:
containers:
- name: monolith
image: udacity/example-monolith:1.0.0
args:
- "-http=0.0.0.0:80"
- "-health=0.0.0.0:81"
- "-secret=secret"
ports:
- name: http
containerPort: 80
- name: health
containerPort: 81
resources:
limits:
cpu: 0.2
memory: "10Mi"
Create the monolith pod
kubectl create -f pods/monolith.yaml
View stdin logs
# One-time poll
kubectl logs monolith
# Streaming
kubectl logs -f monolith
Port Forwarding
kubectl port-forward monolith 10080:80
Pod selection by labels
kubectl get pods -l "app=monolith, secure=enabled"
You can use the kubectl exec command to run an interactive shell inside the monolith Pod. This can come in handy when you want to troubleshoot from within a container:
# Similar to docker-compose exec <service> /bin/sh, right?
kubectl exec monolith --stdin --tty -c monolith /bin/sh
Command Patterns
kubectl get/create/delete/describe serverices/pods
# or
kubectl create -f definitionInFile.yaml
Rolling Update 1000 pods with deployment yaml replicas
Questions
转载于:https://www.jianshu.com/p/19ca13cde0c3
上一篇: LayoutInflater使用
下一篇: 图标(drawable)着色
推荐阅读
-
GCP - Kubernetes study notes
-
study notes for python
-
MySql Study Notes
-
Python study notes Day 2 ‘for‘ loop and ‘while‘ loop
-
Python study notes Day 4 tuple
-
Python study notes Day 6 ‘Dictionaries‘
-
Python study notes Day 1 ‘print‘
-
jQuery Study Notes学习笔记 (二)_jquery
-
JQuery Study Notes 学习笔记(一)_jquery
-
jQuery Study Notes学习笔记 (二)_jquery