Solution TP 10

/images/k8s.jpeg

TP10 - Pod priority class

🇫🇷 Version Française

Priority class

Manifest de deux priority class :

1apiVersion: scheduling.k8s.io/v1
2kind: PriorityClass
3metadata:
4  name: pod-priority-dev
5value: 100
6description: 'Priority class used for development environment'
1apiVersion: scheduling.k8s.io/v1
2kind: PriorityClass
3metadata:
4  name: pod-priority-acc
5value: 500
6description: 'Priority class used for acceptance environment'

Manifest du deployment backend avec référence vers la priority class d’acc :

 1kind: Deployment
 2apiVersion: apps/v1
 3metadata:
 4  name: back-training-app
 5  namespace: form-k8s-acc
 6spec:
 7  replicas: 1
 8  selector:
 9    matchLabels:
10      app: back-training-app
11  template:
12    metadata:
13      labels:
14        app: back-training-app
15    spec:
16      priorityClassName: pod-priority-acc
17      containers:
18        - name: back-training-app
19          image: axelpereira/k8s-training-test-app-back:1.3
20          imagePullPolicy: Always
21          readinessProbe:
22            httpGet:
23              path: /health
24              port: 5000
25            initialDelaySeconds: 3
26            timeoutSeconds: 10
27          livenessProbe:
28            httpGet:
29              path: /health
30              port: 5000
31            initialDelaySeconds: 5
32            failureThreshold: 2
33            periodSeconds: 5
34          resources:
35            requests:
36              memory: '1G'
37            limits:
38              memory: '1G'
39          env:
40            - name: MONGO_USERNAME
41              valueFrom:
42                secretKeyRef:
43                  name: back-secret
44                  key: MONGO_USERNAME
45            - name: MONGO_PASSWORD
46              valueFrom:
47                secretKeyRef:
48                  name: back-secret
49                  key: MONGO_PASSWORD
50            - name: MONGO_HOSTNAME
51              valueFrom:
52                configMapKeyRef:
53                  name: back-configmap
54                  key: MONGO_HOSTNAME
55            - name: MONGO_PORT
56              valueFrom:
57                configMapKeyRef:
58                  name: back-configmap
59                  key: MONGO_PORT
60            - name: MONGO_DB
61              valueFrom:
62                configMapKeyRef:
63                  name: back-configmap
64                  key: MONGO_DB
🇬🇧 English version

Priority class

Two priority class manifests :

1apiVersion: scheduling.k8s.io/v1
2kind: PriorityClass
3metadata:
4  name: pod-priority-dev
5value: 100
6description: 'Priority class used for development environment'
1apiVersion: scheduling.k8s.io/v1
2kind: PriorityClass
3metadata:
4  name: pod-priority-acc
5value: 500
6description: 'Priority class used for acceptance environment'

Backend deployment manifest with reference to the priority class of acc :

 1kind: Deployment
 2apiVersion: apps/v1
 3metadata:
 4  name: back-training-app
 5  namespace: form-k8s-acc
 6spec:
 7  replicas: 1
 8  selector:
 9    matchLabels:
10      app: back-training-app
11  template:
12    metadata:
13      labels:
14        app: back-training-app
15    spec:
16      priorityClassName: pod-priority-acc
17      containers:
18        - name: back-training-app
19          image: axelpereira/k8s-training-test-app-back:1.3
20          imagePullPolicy: Always
21          readinessProbe:
22            httpGet:
23              path: /health
24              port: 5000
25            initialDelaySeconds: 3
26            timeoutSeconds: 10
27          livenessProbe:
28            httpGet:
29              path: /health
30              port: 5000
31            initialDelaySeconds: 5
32            failureThreshold: 2
33            periodSeconds: 5
34          resources:
35            requests:
36              memory: '1G'
37            limits:
38              memory: '1G'
39          env:
40            - name: MONGO_USERNAME
41              valueFrom:
42                secretKeyRef:
43                  name: back-secret
44                  key: MONGO_USERNAME
45            - name: MONGO_PASSWORD
46              valueFrom:
47                secretKeyRef:
48                  name: back-secret
49                  key: MONGO_PASSWORD
50            - name: MONGO_HOSTNAME
51              valueFrom:
52                configMapKeyRef:
53                  name: back-configmap
54                  key: MONGO_HOSTNAME
55            - name: MONGO_PORT
56              valueFrom:
57                configMapKeyRef:
58                  name: back-configmap
59                  key: MONGO_PORT
60            - name: MONGO_DB
61              valueFrom:
62                configMapKeyRef:
63                  name: back-configmap
64                  key: MONGO_DB

Latest Posts