Odf install

From Essential
Revision as of 11:33, 27 June 2023 by Tcepo (talk | contribs) (Created page with "==OPENSHIFT STORAGE/ODF== #https://red-hat-storage.github.io/ocs-training/training/ocs4/ocs4-install-no-ui.html#_installing_openshift_container_storage #https://access.redhat....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

OPENSHIFT STORAGE/ODF

  1. https://red-hat-storage.github.io/ocs-training/training/ocs4/ocs4-install-no-ui.html#_installing_openshift_container_storage
  2. https://access.redhat.com/articles/5692201
#!/bin/bash

#. ~/OPENSHIFT_INSTALL_VARS.sh
#set -a
#majorVersion=$(echo ${versionOPENSHIFT} |sed -rn 's#^([0-9]+\.[0-9]+)(|.[0-9\.]+)$#\1#p' )
#set +a
kubectl get nodes |sed -rn 's#^([[:graph:]]+)[[:space:]].*\bstorage\b.*$#\1#p' |while read i ;do
  oc label node $i node-role.kubernetes.io/storage=''
  oc label node $i cluster.ocs.openshift.io/openshift-storage=''
done
# localstorage operator
cat <<EOF | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
 name: openshift-local-storage
spec: {}
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
 name: local-operator-group
 namespace: openshift-local-storage
spec:
 targetNamespaces:
 - openshift-local-storage
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
 name: local-storage-operator
 namespace: openshift-local-storage
spec:
# channel: "${majorVersion}"  # <-- Channel should be used corresponding to the OCP version being used.
 installPlanApproval: Automatic
 name: local-storage-operator
 source: redhat-operators  # <-- Modify the name of the redhat-operators catalogsource if not default
 sourceNamespace: openshift-marketplace
EOF
while (! kubectl get LocalVolumeDiscovery 2>/dev/null ) ;do
  sleep 10
done
cat <<EOF | oc apply -f -
apiVersion: local.storage.openshift.io/v1alpha1
kind: LocalVolumeDiscovery
metadata:
 name: auto-discover-devices
 namespace: openshift-local-storage
spec:
 nodeSelector:
   nodeSelectorTerms:
     - matchExpressions:
       - key: cluster.ocs.openshift.io/openshift-storage
         operator: In
         values:
           - ""
EOF
#oc get localvolumediscoveries -n openshift-local-storage
#oc get localvolumediscoveryresults -n openshift-local-storage
cat << EOF |oc create -f -
apiVersion: local.storage.openshift.io/v1alpha1
kind: LocalVolumeSet
metadata:
 name: local-block
 namespace: openshift-local-storage
spec:
 nodeSelector:
   nodeSelectorTerms:
     - matchExpressions:
         - key: cluster.ocs.openshift.io/openshift-storage
           operator: In
           values:
             - ""
 storageClassName: localblock
 volumeMode: Block
 fstype: ext4
 maxDeviceCount: 1  # <-- Maximum number of devices per node to be used
 deviceInclusionSpec:
   deviceTypes:
   - disk
#   - part   # <-- Remove this if not using partitions
   deviceMechanicalProperties:
   #- NonRotational #not working with VMWARE, need SSD or NVME
   - Rotational #working with VMWARE
   #minSize: 0Ti   # <-- Uncomment and modify to limit the minimum size of disk used
   #maxSize: 0Ti   # <-- Uncomment and modify to limit the maximum size of disk used
EOF
#oc get pv -n openshift-local-storage
#Add data disk
#Resize other disks
cat <<EOF | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
 labels:
   openshift.io/cluster-monitoring: "true"
 name: openshift-storage
spec: {}
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
 name: openshift-storage-operatorgroup
 namespace: openshift-storage
spec:
 targetNamespaces:
 - openshift-storage
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
 name: ocs-operator
 namespace: openshift-storage
spec:
# channel: "stable-${majorVersion}"  # <-- Channel should be modified depending on the OCS version to be installed. Please ensure to maintain compatibility with OCP version
 installPlanApproval: Automatic
 name: ocs-operator
 source: redhat-operators  # <-- Modify the name of the redhat-operators catalogsource if not default
 sourceNamespace: openshift-marketplace
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
 name: odf-operator
 namespace: openshift-storage
spec:
# channel: "stable-${majorVersion}" # <-- Channel should be modified depending on the OCS version to be installed. Please ensure to maintain compatibility with OCP version
 installPlanApproval: Automatic
 name: odf-operator
 source: redhat-operators  # <-- Modify the name of the redhat-operators catalogsource if not default
 sourceNamespace: openshift-marketplace
EOF
while (! kubectl get StorageCluster 2>/dev/null ) ;do
  sleep 10
done
while [ -z "${sizeDisk}" ] ;do
  sleep 10
  sizeDisk=$(kubectl get pv --no-headers |sed -rn 's#^[^[:space:]]+[[:space:]]+([^[:space:]]+)[[:space:]].*$#\1#p' |head -1 )
done
#sleep 160
#>storagecluster.yaml
cat <<EOF |kubectl create -f -
apiVersion: ocs.openshift.io/v1
kind: StorageCluster
metadata:
 name: ocs-storagecluster
 namespace: openshift-storage
spec:
 manageNodes: false
 resources:
   mds:
     limits:
       cpu: "1" #default 3
       memory: "4Gi" #default 8
     requests:
       cpu: "1" #default 3
       memory: "4Gi" #default 8
 monDataDirHostPath: /var/lib/rook
 storageDeviceSets:
 - count: 1  # <-- Modify count to desired value. For each set of 3 disks increment the count by 1.
   dataPVCTemplate:
     spec:
       accessModes:
       - ReadWriteOnce
       resources:
         requests:
           storage: "${sizeDisk}"  # <-- This should be changed as per storage size. Minimum 100 GiB and Maximum 4 TiB
       storageClassName: localblock
       volumeMode: Block
   name: ocs-deviceset
   placement: {}
   portable: false
   replica: 3 #default 3, minimum 2
   resources:
     limits:
       cpu: "1" #default 2
       memory: "2Gi"  #default 5
     requests:
       cpu: "1" #default 2
       memory: "2Gi"  #default 5
EOF
#oc create -f storagecluster.yaml
while (! kubectl get storageclass ocs-storagecluster-ceph-rbd 2>/dev/null ) ;do
  sleep 20
done
#oc get pods -n openshift-storage
#oc get csv -n openshift-storage
#debug
#kubectl get events -n openshift-storage
#rollback last action
#oc delete -n openshift-storage storagecluster --all --wait=true
#change default class
#https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/
#kubectl get storageclass

kubectl patch storageclass thin -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
kubectl patch storageclass ocs-storagecluster-ceph-rbd -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

#ENABLE SNAPSHOT DEFAULT&NAME
#https://github.com/rook/rook/blob/91beb549be3720a1278c3b5c67934f46555e1db5/deploy/examples/csi/rbd/snapshotclass.yaml

#cat <<EOF |kubectl apply -f -
#apiVersion: snapshot.storage.k8s.io/v1
#deletionPolicy: Delete
#driver: openshift-storage.rbd.csi.ceph.com
#kind: VolumeSnapshotClass
#metadata:
#  name: csi-hostpath-snapclass
#  annotations:
#    snapshot.storage.kubernetes.io/is-default-class: "true"
#parameters:
#  clusterID: openshift-storage
#  csi.storage.k8s.io/snapshotter-secret-name: rook-csi-rbd-provisioner
#  csi.storage.k8s.io/snapshotter-secret-namespace: openshift-storage
#EOF