发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967
课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。
腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518
第二个视频发布 https://edu.csdn.net/course/detail/27109
介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。
第四个课程发布:https://edu.csdn.net/course/detail/28488
本课程将详细介绍k8s所有命令,以及命令的go源码分析,学习知其然,知其所以然
————————————————
Api版本:
•autoscaling/v1 #只支持通过cpu为参考依据,来改变pod副本数
autoscaling/v2beta1 #支持通过cpu、内存、连接数以及用户自定义的资源指标数据为参考依据。
autoscaling/v2beta2 #同上,小的变动
targetAverageUtilization:
[root@master01 targetCPUUtilizationPercentage]# cat ./*
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nginx-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-deployment
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 50
apiVersion: v1
kind: Service
metadata:
name: nginx-clusterip-svc
spec:
selector:
app: nginx
type: ClusterIP
ports:
- name: http
port: 8000
targetPort: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
resources:
requests:
cpu: 0.01
limits:
cpu: 0.01
targetAverageValue:
[root@master01 targetAverageValue]# cat ./*
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: tomcat-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: tomcat-deployment
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageValue: 80m
- type: Resource
resource:
name: memory
targetAverageValue: 150Mi
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
labels:
app: tomcat
spec:
selector:
matchLabels:
app: tomcat
replicas: 2
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat
ports:
- containerPort: 8080
resources:
requests:
cpu: 0.1
memory: 100Mi
limits:
cpu: 0.2
memory: 200Mi
apiVersion: v1
kind: Service
metadata:
name: tomcat-clusterip-svc
spec:
selector:
app: tomcat
type: ClusterIP
ports:
- name: http
port: 8000
targetPort: 8080
targetAverageUtilization:
[root@master01 targetAverageUtilization]# cat ./*
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: tomcat-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: tomcat-deployment
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
- type: Resource
resource:
name: memory
targetAverageUtilization: 150
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
labels:
app: tomcat
spec:
selector:
matchLabels:
app: tomcat
replicas: 2
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat
ports:
- containerPort: 8080
resources:
requests:
cpu: 0.1
memory: 100Mi
limits:
cpu: 0.2
memory: 200Mi
apiVersion: v1
kind: Service
metadata:
name: tomcat-clusterip-svc
spec:
selector:
app: tomcat
type: ClusterIP
ports:
- name: http
port: 8000
targetPort: 8080
replicaset:
[root@master01 replicaset]# cat ./*
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: frontend-hpa
labels:
software: apache
project: frontend
app: hpa
version: v1
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: ReplicaSet
name: frontend
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 30
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# this replicas value is default
# modify it according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
matchExpressions:
- {key: tier, operator: In, values: [frontend]}
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: iaasfree/gb-frontend:v3
resources:
requests:
cpu: 10m
memory: 10Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service, then to
# instead access environment variables to find service host
# info, comment out the 'value: dns' line above, and uncomment the
# line below.
# value: env
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: frontend-svc
spec:
selector:
tier: frontend
type: ClusterIP
ports:
- name: http
port: 8000
targetPort: 80