Difference between revisions of "Openebs"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 11: Line 11:
 
kubectl patch storageclass openebs-jiva-default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
 
kubectl patch storageclass openebs-jiva-default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
 
kubectl patch storageclass microk8s-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
 
kubectl patch storageclass microk8s-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
 +
```
 +
 +
deployment-claim-example.yaml
 +
```
 +
apiVersion: apps/v1
 +
kind: Deployment
 +
metadata:
 +
name: busybox
 +
labels:
 +
  app: busybox
 +
spec:
 +
replicas: 2
 +
strategy:
 +
  type: RollingUpdate
 +
selector:
 +
  matchLabels:
 +
    app: busybox
 +
template:
 +
  metadata:
 +
    labels:
 +
      app: busybox
 +
  spec:
 +
    containers:
 +
    - resources:
 +
          limits:
 +
          cpu: 0.5
 +
      name: busybox
 +
      image: busybox
 +
      command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
 +
      imagePullPolicy: IfNotPresent
 +
      ports:
 +
        - containerPort: 3306
 +
          name: busybox
 +
      volumeMounts:
 +
      - mountPath: /var/lib/mysql
 +
        name: demo-vol1
 +
    volumes:
 +
      - name: demo-vol1
 +
        persistentVolumeClaim:
 +
        claimName: busk-claim-jiva
 +
---
 +
kind: PersistentVolumeClaim
 +
apiVersion: v1
 +
metadata:
 +
name: busk-claim-jiva
 +
spec:
 +
storageClassName: openebs-jiva-default
 +
accessModes:
 +
  - ReadWriteOnce
 +
resources:
 +
  requests:
 +
    storage: 5G
 +
---
 +
apiVersion: v1
 +
kind: Service
 +
metadata:
 +
name: busybox-mysql
 +
labels:
 +
  name: busybox-mysql
 +
spec:
 +
ports:
 +
  - port: 3306
 +
    targetPort: 3306
 +
selector:
 +
    name: busybox
 
```
 
```
  

Revision as of 00:30, 19 June 2021

Ubuntu Microk8s

sudo systemctl status iscsid
# sudo systemctl enable --now iscsid
sudo systemctl status iscsid | grep inactive && sudo systemctl enable --now iscsid
sudo microk8s dns ingress rbac openebs
watch sudo microk8s kubectl get pod -n openebs
kubectl patch storageclass openebs-jiva-default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
kubectl patch storageclass microk8s-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

deployment-claim-example.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
 name: busybox
 labels:
   app: busybox
spec:
 replicas: 2
 strategy:
   type: RollingUpdate
 selector:
   matchLabels:
     app: busybox
 template:
   metadata:
     labels:
       app: busybox
   spec:
     containers:
     - resources:
          limits:
           cpu: 0.5
       name: busybox
       image: busybox
       command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
       imagePullPolicy: IfNotPresent
       ports:
        - containerPort: 3306
          name: busybox
       volumeMounts:
       - mountPath: /var/lib/mysql
         name: demo-vol1
     volumes:
      - name: demo-vol1
        persistentVolumeClaim:
         claimName: busk-claim-jiva
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
 name: busk-claim-jiva
spec:
 storageClassName: openebs-jiva-default
 accessModes:
   - ReadWriteOnce
 resources:
   requests:
     storage: 5G
---
apiVersion: v1
kind: Service
metadata:
 name: busybox-mysql
 labels:
   name: busybox-mysql
spec:
 ports:
   - port: 3306
     targetPort: 3306
 selector:
     name: busybox
An example of creating a PersistentVolumeClaim utilizing the openebs-hostpath StorageClass


kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: local-hostpath-pvc
spec:
  storageClassName: openebs-hostpath
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5G



-----------------------

If you are planning to use OpenEBS with multi nodes, you can use the openebs-jiva-default StorageClass.
An example of creating a PersistentVolumeClaim utilizing the openebs-jiva-default StorageClass


kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jiva-volume-claim
spec:
  storageClassName: openebs-jiva-default
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5G

Example