this blog is consists of topics within intro to K8s.
Welcome to learn k8s with me!!! [Kubernetes Crash Course for Absolute Beginners NEW] - YouTube
a container orchestration tool.
the rise of containers in microservices technology actually resulted in applications that are now comprised of hundreds or sometimes maybe thousands of containers.
Managing those loads of containers across multiple environments using scripts and self-made tools an be really complex and sometimes even impossible.
master nodes are much more important than worker nodes
Node: a virtual or physical machine
IP adjust every time the pod restart,so -> service
Ingress: cause the node-ip is not very practical.
change name: mogo-db-service -> mogo-db
! ConfigMap is for non-confidential data only! ->Secret
my-app died -> replicates everything!
Define blueprint for Pods: specify how many replicas you want to have
work with deployments instead of pods.
! DB can’t be replicated via Deployment!
DB has state -> data inconsistence - > StatefulSet
however, deploying StatefulSet not easy -> common practice: DB hosted outside of k8s cluster.
talk to API server
C-M
each configuration file has 3 parts
复查一下哪里出错了。
**MiniKube **
Master and Node processes run in ONE machine
Node: docker runtime pre-installed.
Kubeetcl: Command line tool for K8s cluster - interact
https://minikube.sigs.k8s.io/docs/start/
container or VM environment
本文参考环境:MacOS Sonoma 14.2
brew install hyperkit
Docker prefered!
minikube start --vm-driver docker
也不行,miniKube FAQ已经为我们提供方法权限问题按提示修改即可。
minikube start --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
Or Start your cluster
minikube start --vm-driver=hyperkit
get status of nodes
kubectl get nodes
minikube status
**MongoDB Endpoint **
echo -n mogouser | base64
echo -n mogopassword | base64
mongo.yaml - Deployment & Service in 1 file, because they belong together.
label: for pods, label is a required field. for other compoments, it is optional.
Selector: which Pods belong to Deployment?
Service: ---
= you can have multiple YAML configurations within a file
simple to keep port and target port the same.
How do we pass these environment variables to mongo application?
same with password
similar with webapp:
Configure external Service
get all components in cluster
kubectl get all
kubectl get pod | configmap | secret
kubectl --help
kubectl get pod
kubectle logs
Acess WebApp in Browser
kubectl get svc
minikube ip
不知道怎么回事,上面的不行,下面的行
minikube service webapp-service --url
minikube start --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
kubectl create deployment nginx-delp --image=nginx
replicaset : a layer between deployment and pod.
kubectl get replicaset
Everything below Deployment is handled by k8s.
So let’s make a change. ->deployment
kubectl edit deployment nginx-depl
Auto-genetated configuration file with default values:
Debug pods
kubectl logs [pod-name]
Eg.
kubectl create deployment mongo-depl --image=mongo
kubectl get pod
kubectl logs mongo-depl-558475c797-sb8nb
kubectl describe pod [pod name]
Enter the container
kubectl exec -it [pod name] -- bin/bash
Delete deplyment & Apply configuration file
kubectl delete deployment [name]
Configuration files is a better way.
kubectl apply -f [file name]
Summarize
https://www.youtube.com/watch?v=UPJpmOKGKzU
看完三小时的课程后,学习openFaas,部署k3s+openfaas