Kubernetes
docker
- https://docs.docker.com/engine/install/ubuntu/#installation-methods
minikube
minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.
minikube start
alias kubectl="minikube kubectl --"
kubectl proxy --address='0.0.0.0' --port=8002 --accept-hosts='^*$'
Starting to serve on [::]:8002
http://192.168.0.171:8002/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/pod?namespace=default
FAQ 遇到 Exiting due to DRV_NOT_HEALTHY: Found driver(s) but none were healthy. See above for suggestions how to fix installed drivers.
sudo usermod -aG docker $USER && newgrp docker
k8s
- create namespace:
kubectl create ns {name} - create deployment :
kubectl {namespace} {create/apply} -f manifests/{service_name}- example:
kubectl -n{name} apply -f manifests/manifests/swagger.yaml
- example:
- get service:
kubectl -n{name} get service
deploy a service
-
write a yaml file to create a deployment.
-
create deploment:
kubectl {namespace} create -f manifests/{service_name} -
checking pod status:
kubectl -n{name} get pod -
checkout node:
kuberctl get node -
find a node and find hostname:
kubectl describe node {nodeid} | grep hostname -
go to [K8S dev], select Load Balancer product, paste the hostname and port predefined on the yaml file.
-
make sure your load balancer is running and ipv4 is up
-
checkout vip
-
go to [K8S dev] select DNS product, create a record with the vip
# Deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: swagger-tools
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: swagger-tools
template:
metadata:
labels:
app.kubernetes.io/name: swagger-tools
spec:
containers:
- name: swagger-tools
image: swaggerapi/swagger-editor
imagePullPolicy: Always
env:
- name: NAME
value: noname
ports:
- name: http
containerPort: 8080
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 1
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 10m
memory: 16Mi
limits:
cpu: 300m
memory: 384Mi
# Service
---
apiVersion: v1
kind: Service
metadata:
name: swagger-tools
labels:
app.kubernetes.io/name: swagger-tools
spec:
type: NodePort
selector:
app.kubernetes.io/name: swagger-tools
ports:
- name: http
port: 80
nodePort: 30138
protocol: TCP
targetPort: http