KinD

These are the KinD notes. Kubernetes IN Docker.

Installation

To install on Linux:

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

Storage

  1. Create a directory on your laptop that will serve as the Persistent Volume (PV).
  2. Create a YAML file for the PV and PVC, specifying the path to the directory on your laptop as the source of the PV.
  3. Apply the YAML file to your KIND cluster to create the PV and PVC.
  4. In your pod specification, refer to the PVC by its name to mount the volume.

Here is an example of a YAML file for the PV and PVC:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /path/to/your/laptop/directory
  persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

To apply the YAML file, run:

kubectl apply -f pv-pvc.yaml

In your pod specification, refer to the PVC by its name to mount the volume:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mycontainer
    image: myimage
    volumeMounts:
    - name: mypv
      mountPath: /path/in/container
  volumes:
  - name: mypv
    persistentVolumeClaim:
      claimName: mypvc