damitj07
damitj07

Reputation: 2919

how do I enable mount propagation in Rancher - Kubernetes feature gates?

How can I enable feature gates for my cluster in Rancher 2.0? I am in need of enabling the --feature-gates MountPropagation=true. This will enable me to use storage solutions like StorageOS, CephFS, etc

There are 2 use cases here :

  1. If the Rancher is setup already and running?
  2. If I am setting up the cluster from scratch?

Upvotes: 4

Views: 4581

Answers (4)

Timofey Drozhzhin
Timofey Drozhzhin

Reputation: 4734

For those Running Rancher on a Single Node Using Docker

If you need to enable mount propagation, or you're getting the following error installing Longhorn

spec: failed to generate spec: path "/var/lib/longhorn/" is mounted on "/" but it is not a shared mount

There are a few ways you can fix this.

Option 1 - Enable Propagation After Setup

You can manually enable propagation at any time, without the need to restart. Run mount --make-rshared / inside your Rancher container. Make sure to include the "r" in the flag "--make-rshared" for recursive sharing. More information on this blog.

Option 2 - Enable Propagation During Setup

You can run the command before the entrypoint.sh, like this:

services:
  rancher:
    image: rancher/rancher:latest
    restart: unless-stopped
    ports:
      - 8080:80
      - 8443:443
    environment:
      - CATTLE_SKIP_CERTIFICATE_VALIDATION=true
    privileged: true
    # Enable mount propagation
    entrypoint:
      - bash
      - -c
      - |
        mount --make-rshared /
        /usr/bin/entrypoint.sh

Upvotes: 0

Petr
Petr

Reputation: 264

I was strugling with enabling feature gate TTLAfterFinished. (same as MountPropagation=true)

Rancher v2.3.3

step 1: Open Rancher2.3.3 UI

step 2: Click edit cluster

step 3: Click the button "edit as YAML" next to "Cluster Options"

step 4: You need to add feature gate to all cluster services (see below)

step 5: add or edit extra_args similar to this:

    ...
        kube-api:
          extra_args:
            feature-gates: TTLAfterFinished=true
    ...
        kube-controller:
          extra_args:
            feature-gates: TTLAfterFinished=true
    ...
        kubelet:
          extra_args:
            feature-gates: TTLAfterFinished=true
    ...  

Replace TTLAfterFinished with your feature gate. LIST HERE

Upvotes: 3

simohe
simohe

Reputation: 671

alternative (test is pending, blocked by https://github.com/rancher/rancher/issues/26261):

step 1: Open Rancher2.0 UI

step 2: Click edit for cluster (in menu with three vertical dots)

step 3: Click the button "edit as YAML" next to "Cluster Options"

step 4: find "services.kubelet" (or "services.WhatYouNeed")

step 5: add or edit extra_args similar to this:

    kubelet:
      extra_args:
        feature-gates: rancherKubernetesEngineConfig=true

(according to https://rancher.com/docs/rke/latest/en/config-options/services/services-extras/#extra-args)

step 6: click save (at bottom)

create new cluster

You can also edit "Cluster Options" as yaml when creating a new cluster. Probably this can also be included as an "rke template".

Upvotes: 1

damitj07
damitj07

Reputation: 2919

Hello and hope this helps someone, After much googling and help from awesome people at Rancher I got the solution for this. Here is what you can do to set the feature gates flags for the Kubernetes engine RKE.

step 1: Open Rancher2.0 UI

step 2: View cluster in API

enter image description here

step 3: Click edit and modify the rancherKubernetesEngineConfig input box

enter image description here

  • Find the services key.
  • Then add extra args for kubelet in below format

    "services": {
    "etcd": { "type": "/v3/schemas/etcdService" },
    "kubeApi": {
        "podSecurityPolicy": false,
        "type": "/v3/schemas/kubeAPIService",
        "extraArgs": { "feature-gates": "PersistentLocalVolumes=true, VolumeScheduling=true,MountPropagation=true" }
    },
    "kubeController": { "type": "/v3/schemas/kubeControllerService" },
    "kubelet": {
        "failSwapOn": false,
        "type": "/v3/schemas/kubeletService",
        "extraArgs": { "feature-gates": "PersistentLocalVolumes=true, VolumeScheduling=true,MountPropagation=true" }
    }
    

step 4: Click show request .. you get a curl command and json request.

step 5: Verify the request body data which will be shown.

step 6: Make sure the key's which are not applicable are set to null. e.g amazonElasticContainerServiceConfig, azureKubernetesServiceConfig, googleKubernetesEngineConfig all need to null for me.

step 7: Click send request

You should get a response with status code 201. And your cluster will start updating. You can verify that your cluster RKE has updated by viewing the Cluster in API again.

Upvotes: 7

Related Questions