Running pre- and post- install scripts.

Running pre- and post- install scripts.

Overview

Users may need to run additional commands during cluster provisioning. Kublr provides a way to run pre- and post- install scripts that will be executed before and after Kublr-agent installation on each host of the cluster.

How to use it.

ClusterSpec allows users to provide a list of commands to be executed during Kubernetes cluster provisioning.

Kublr allows you to specify the commands that will be executed before and after Kubernates installation.

Note that platform requirements are checked after the preinstall script is executed, so this script can mount volumes, install or uninstall packages, enable or disable subsystems and do other things to bring the system to Kublr installation requirements.

To do this, add the appropriate fields to the cluster specification:

  1. Before starting the cluster creation, open the cluster specification by clicking the ‘Cluster creation specification’

  2. Add the following block to the required instance group:

    kublrAgentConfig:
    kublr:
        setup:
        cmd:
            before: ["/bin/sh", "-c", "command 1; ...; commandn"]
            after: ["/bin/sh", "-c", "command 1; ...; commandn"]
    
  3. Start cluster creation

Example

The following cluster specification will disable ‘noexec’ flag on /tmp before installation and enable it after successful installation:

kind: Cluster
metadata:
  ownerReferences: []
  name: MyCluster
  space: MySpace
spec:
  master:
    locations:
      -
        baremetal:
          hosts:
            -
              address: 192.168.1.1
        locationRef: bare-metal1
    minNodes: 1
    name: master
    kublrAgentConfig:
      kublr:
        setup:
          cmd:
            before: ["/bin/sh", "-c", "mount -oremount,exec /tmp"]
            after: ["/bin/sh", "-c", "mount -oremount,noexec /tmp"]
  locations:
    -
      name: bare-metal1
      baremetal: {}
  nodes:
    -
      locations:
        -
          baremetal: {}
          locationRef: bare-metal1
      minNodes: 2
      name: default
      kublrAgentConfig:
        kublr:
          setup:
            cmd:
              before: ["/bin/sh", "-c", "mount -oremount,exec /tmp"]
              after: ["/bin/sh", "-c", "mount -oremount,noexec /tmp"]