Skip to content

Instantly share code, notes, and snippets.

@acsulli
Created March 5, 2021 14:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acsulli/afe6e6d35d68dfb20391058e30602ba6 to your computer and use it in GitHub Desktop.
Save acsulli/afe6e6d35d68dfb20391058e30602ba6 to your computer and use it in GitHub Desktop.
#! /usr/bin/env/sh
#
# this script has not been tested nor validated, it is not, in any way
# supported by Red Hat or NetApp. use at your own risk.
#
#
# the purpose of this script is to create an OpenShift MachineConfig
# to apply the NetApp recommended OS configuration to RHCOS machines.
# it does this by creating a shell script on the node, then executing
# the script via a unit file on startup.
#
WORKER_CONFIG=$(cat << EOF | base64 -w0
#! /usr/bin/env sh
#
# refer to Trident documentation for configuration tasks
# https://netapp-trident.readthedocs.io/en/stable-v21.01/kubernetes/operations/tasks/worker.html
#
# this script is triggered by a boot-time unit file, netapp-ontap-iscsi-config.service
#
# set scanning to manual
sed -i 's/^\(node.session.scan\).*/\1 = manual/' /etc/iscsi/iscsid.conf
# configure multipathd
mpathconf --enable --with_multipathd y
#
# multipathd and iscsi services are enabled by ignition
#
EOF
)
WORKER_MACHINE_CONFIG=$(cat << EOF
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: worker-iscsi-configuration
spec:
config:
ignition:
version: 3.1.0
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,$WORKER_CONFIG
filesystem: root
mode: 493
path: /usr/local/bin/configure_ontap_iscsi.sh
systemd:
units:
- name: iscsid.service
enabled: true
- name: multipathd.service
enabled: true
- name: netapp-ontap-iscsi-config.service
contents: >
[Unit]
Description=NetApp ONTAP iSCSI Configuration
Before=multipathd.service
Before=iscsid.service
[Service]
Type=oneshot
ExecStart=/bin/bash /usr/local/bin/configure_ontap_iscsi.sh
[Install]
WantedBy=multi-user.target
enabled: true
osImageURL: ""
EOF
)
echo $WORKER_MACHINE_CONFIG | oc apply -f -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment