0.97M

k8s доклад

1.

Kubernetes: полный вперед!

2.

Общее устройство кластера

3.

POD

4.

POD
apiVersion: v1
kind: Pod
metadata:
name: example-pod
labels:
app: example
spec:
containers:
- name: example-container
image: nginx:1.21.6
ports:
- containerPort: 80

5.

ReplicaSet
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: example-replicaset
spec:
replicas: 3
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
containers:
- name: example-container
image: nginx:1.21.6
ports:
- containerPort: 80

6.

Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
containers:
- name: example-container
image: nginx:1.21.6
ports:
- containerPort: 80

7.

Как регулировать, на каких
нодах будут запускаться
поды?

8.

Node Selector
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
nodeSelector:
key: value
containers:
- name: my-container
image: nginx

9.

Node Affinity
apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
...
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: environment
operator: In
values:
- production
...

10.

Node Affinity
apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
...
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nginx
topologyKey: "kubernetes.io/hostname"

11.

Topology Spread Constraints
apiVersion: apps/v1
kind: Deployment
...
spec:
replicas: 6
...
template:
...
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: DoNotSchedule
labelSelector: matchLabels:
app: my-app
...

12.

StatefulSet
apiVersion: apps/v1
kind: StatefulSet
...
spec:
replicas: 3
...
serviceName: "example-service"
template:
...
spec:
containers:
...
volumeMounts:
- name: data
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi

13.

14.

Service
apiVersion: v1
kind: Service
metadata:
name: grafana-service
labels:
app: grafana
spec:
type: ClusterIP
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000

15.

ClusterIP

16.

Node Port
apiVersion: v1
kind: Service
metadata:
name: grafana-service
labels:
app: grafana
spec:
type: NodePort
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000
nodePort: 32000

17.

Node Port

18.

LoadBalancer
apiVersion: v1
kind: Service
metadata:
name: grafana-service
labels:
app: grafana
spec:
type: LoadBalancer
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000

19.

LoadBalancer

20.

21.

DaemonSet
apiVersion: apps/v1
kind: DaemonSet
...
spec:
selector:
matchLabels:
app: prometheus-node-exporter
template:
metadata: ...
spec:
containers:
- name: node-exporter
image: prom/node-exporter:v1.6.0
ports:
- containerPort: 9100
name: http
securityContext:
...
hostNetwork: true
hostPID: true

22.

23.

values.yaml
replicaCount: 3
image:
repository: nginx
tag: "1.21.6"
pullPolicy: IfNotPresent
service:
name: nginx-service
type: ClusterIP
port: 80
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
ingress:
enabled: false
annotations: {}
hosts:
- host: nginx.local
paths:
- /

24.

Templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
replicas: {{ .Values.replicaCount }}
selector: ...
template:
metadata: ...
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
resources:
requests:
memory: {{ .Values.resources.requests.memory }}
cpu: {{ .Values.resources.requests.cpu }}
limits:
memory: {{ .Values.resources.limits.memory }}
cpu: {{ .Values.resources.limits.cpu }}
English     Русский Правила