原视频: Kubernetes Tutorial for Beginners [in 4 Hours]
Definition
open source container orchestration tool; helps manage containerized applications
Node
3-node processes: ① Kubelet ②Kube Proxy ③Container runtime
Master Node
4-processes:
①Api Server: some request->PAI Server->validates request->...other process..->Pod
②Scheduler: Schedule new Pod->API Server->Scheduler->where to put Pod->Kubelet
③Controller management:Controller Manager->Scheduler->Kubelet->restart Pod
④etcd: cluster brain
YAML Configuration File in Kubenetes
nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
matadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.16
ports:
- containerPort: 8080
template applies to a pod
template.spec is the blueprint for a pod
connection by using labels and selectors: metadata part--labels, specification part--selectors
nginx-service.yaml
apiVersion:v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 8080
the service use same app--nginx to connects with deployment and pods
DB Service --port:80--> nginx Service -- targetPort:8080 --> Pod
external Service
apiVersion:v1
kind: Service
metadata:
name: myapp-external-service
spec:
selector:
app: myapp
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 35010
Ingress
apiVersion: networking.k8s.io/vlbetal
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- host: myapp.com
http:
paths:
- backend:
service: myapp-internal-service
ervicePort:8080
http://my-app.com/<paths>
Internal Service
apiVersion:v1
kind: Service
metadata:
name: myapp-internal-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 8080
targetPort: 8080
should set Ingress Controller Pod
(Proxy Server) --> Ingress Controller Pod --> my-app ingress --> my-app internal Service --> my-app Pod
example for Ingress implementation
First, install Ingress Controller.
kubectl get pod -n kube-system
then can see the controller running in the cluster.
for example, a namespace called kubernetes-dashboard
dashboard-ingress.yaml
apiVersion: networking.k8s.io/vlbetal
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kubernetes-dashboard
spec:
rules:
- host: dashboard.com
http:
paths:
- backend:
service: kubernetes-dashboard
ervicePort: 80
then, create it
kubectl apply -f dashboard-ingress.yaml
and edit the file /etc/hosts
create an Internal Service
Conclusion of IP-Adress
how to know the node?
connection between Ingress and internal Service:
Which Pods for service to forward the request to?