📝 Josh's Notes

Test Deployment Notes

What follows is my, potentially slightly incoherent, stream of consciousness as I try to teach myself Kubernetes

First Deployment

 1---
 2apiVersion: apps/v1
 3kind: Deployment
 4metadata:
 5  name: uptime-kuma
 6  labels:
 7    app: uptime-kuma
 8spec:
 9  replicas: 1
10  selector:
11    matchLabels:
12      app: uptime-kuma
13  template:
14    metadata:
15      labels:
16        app: uptime-kuma
17    spec:
18      containers:
19      - name: uptime-kuma
20        image: louislam/uptime-kuma
21        ports:
22        - containerPort: 3001
23---
24apiVersion: v1
25kind: Service
26metadata:
27  name: uptime-kuma-service
28spec:
29  selector:
30    app: uptime-kuma
31  type: LoadBalancer  
32  ports:
33    - protocol: TCP
34      port: 3001
35      targetPort: 3001
36      nodePort: 30000

Adding Volumes for Persistent Storage

 1---
 2apiVersion: apps/v1
 3kind: Deployment
 4metadata:
 5  name: uptime-kuma
 6  labels:
 7    app: uptime-kuma
 8spec:
 9  replicas: 1
10  selector:
11    matchLabels:
12      app: uptime-kuma
13  template:
14    metadata:
15      labels:
16        app: uptime-kuma
17    spec:
18      containers:
19      - name: uptime-kuma
20        image: louislam/uptime-kuma
21        ports:
22        - containerPort: 3001
23        volumeMounts: # Volume must be created along with volumeMount (see next below)
24        - name: uptime-kuma-data
25          mountPath: /app/data # Path within the container, like the right side of a docker bind mount -- /tmp/data:/app/data
26      volumes: # Defines a volume that uses an existing PVC (defined below)
27      - name: uptime-kuma-data
28        persistentVolumeClaim:
29          claimName: uptime-kuma-pvc
30---
31apiVersion: v1
32kind: Service
33metadata:
34  name: uptime-kuma-service
35spec:
36  selector:
37    app: uptime-kuma
38  type: LoadBalancer  
39  ports:
40    - protocol: TCP
41      port: 3001
42      targetPort: 3001
43      nodePort: 30000
44---
45apiVersion: v1
46kind: PersistentVolume
47metadata:
48  name: uptime-kuma-pv
49spec:
50  accessModes:
51    - ReadWriteOnce
52  capacity:
53    storage: 1Gi
54  storageClassName: standard
55  hostPath:
56    path: /tmp/uptime/data # Path on the host
57---
58apiVersion: v1
59kind: PersistentVolumeClaim
60metadata:
61  name: uptime-kuma-pvc
62spec:
63  accessModes:
64    - ReadWriteOnce
65  resources:
66    requests:
67      storage: 1Gi
68  storageClassName: standard
69  volumeName: uptime-kuma-pv
  Type     Reason            Age    From               Message
  ----     ------            ----   ----               -------
  Warning  FailedScheduling  4m10s  default-scheduler  0/1 nodes are available: persistentvolumeclaim "uptime-kuma-pvc" not found. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
  Warning  FailedScheduling  4m9s   default-scheduler  0/1 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
Events:
  Type     Reason          Age                  From                         Message
  ----     ------          ----                 ----                         -------
  Warning  VolumeMismatch  7s (x26 over 6m20s)  persistentvolume-controller  Cannot bind to requested volume "uptime-kuma-pv": storageClassName does not match

-kubectl describe pv uptime-kuma-pv shows that uptime-kuma-pv has no storage class assigned:

Name:            uptime-kuma-pv
Labels:          <none>
Annotations:     <none>
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    
Status:          Available
NAME                 PROVISIONER                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
standard (default)   k8s.io/minikube-hostpath   Delete          Immediate           false                  2d

Using an SMB share as persistent storage

 1apiVersion: storage.k8s.io/v1
 2kind: StorageClass
 3metadata:
 4  name: smb
 5provisioner: smb.csi.k8s.io
 6parameters:
 7  source: //10.0.30.11/kubernetes-testing
 8  # if csi.storage.k8s.io/provisioner-secret is provided, will create a sub directory
 9  # with PV name under source
10  csi.storage.k8s.io/provisioner-secret-name: smbcreds
11  csi.storage.k8s.io/provisioner-secret-namespace: default
12  csi.storage.k8s.io/node-stage-secret-name: smbcreds
13  csi.storage.k8s.io/node-stage-secret-namespace: default
14reclaimPolicy: Delete  # available values: Delete, Retain
15volumeBindingMode: Immediate
16allowVolumeExpansion: true
17mountOptions:
18  - dir_mode=0777
19  - file_mode=0777
20  - uid=1000
21  - gid=1000

Deploying a StatefulSet

#kubernetes