Similar presentations:
k8s доклад
1.
Kubernetes: полный вперед!2.
Общее устройство кластера3.
POD4.
PODapiVersion: v1
kind: Pod
metadata:
name: example-pod
labels:
app: example
spec:
containers:
- name: example-container
image: nginx:1.21.6
ports:
- containerPort: 80
5.
ReplicaSetapiVersion: 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.
DeploymentapiVersion: 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 SelectorapiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
nodeSelector:
key: value
containers:
- name: my-container
image: nginx
9.
Node AffinityapiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
...
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: environment
operator: In
values:
- production
...
10.
Node AffinityapiVersion: 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 ConstraintsapiVersion: apps/v1
kind: Deployment
...
spec:
replicas: 6
...
template:
...
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: DoNotSchedule
labelSelector: matchLabels:
app: my-app
...
12.
StatefulSetapiVersion: 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.
ServiceapiVersion: v1
kind: Service
metadata:
name: grafana-service
labels:
app: grafana
spec:
type: ClusterIP
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000
15.
ClusterIP16.
Node PortapiVersion: 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 Port18.
LoadBalancerapiVersion: v1
kind: Service
metadata:
name: grafana-service
labels:
app: grafana
spec:
type: LoadBalancer
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000
19.
LoadBalancer20.
21.
DaemonSetapiVersion: 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.yamlreplicaCount: 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.yamlapiVersion: 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 }}