Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable switch to join kubernetes master transparently, if configured #4474

Closed
wants to merge 17 commits into from

Conversation

renukamanavalan
Copy link
Contributor

@renukamanavalan renukamanavalan commented Apr 23, 2020

When configured, hostcfgd watches and call join/reset connection to master, depending on whether IP address is non-empty/empty. If master is not available at that time point, the kube_join script, creates a cron job to retry every 10 minutes, until the server is reachable.

Introduced a new table in config-db:

    "KUBERNETES_MASTER": {
        "SERVER": {
            "IP": "10.10.10.10",
            "insecure": "false"
        }
    }

In Minigraph:
Under <MetadataDeclaration>/<Devices>/<DeviceMetadata>/<Name>...</Name>/<Properties>,
added new entities as below
    <a:DeviceProperty>
       <a:Name>KubernetesMaster</a:Name>
       <a:Reference i:nil="true"/>
       <a:Value>10.10.10.10</a:Value>
    </a:DeviceProperty>
    <a:DeviceProperty>
       <a:Name>KubernetesInsecure</a:Name>
       <a:Reference i:nil="true"/>
       <a:Value>true</a:Value>
    </a:DeviceProperty>

  1. Updated minigraph.py to read & write this new data
  2. Updated hostcfgd to watch "KUBERNETES_MASTER" and call join/reset
    connection to master depending on if IP address is configured or not
  3. Added helper scripts kube_join.sh & kube_reset.sh for join/reset respectively

Code algorithm:
image

Introduced a new table:
    "KUBERNETES_MASTER": {
        "SERVER": {
            "IP": "10.10.10.10",
            "insecure": "false"
        }
    }

In Minigraph:
Under <MetadataDeclaration>/<Devices>/<DeviceMetadata>/<Name>...</Name>/<Properties>,
added new entities as below
    <a:DeviceProperty>
       <a:Name>KubernetesMaster</a:Name>
       <a:Reference i:nil="true"/>
       <a:Value>10.10.10.10</a:Value>
    </a:DeviceProperty>
    <a:DeviceProperty>
       <a:Name>KubernetesInsecure</a:Name>
       <a:Reference i:nil="true"/>
       <a:Value>true</a:Value>
    </a:DeviceProperty>

1) Updated minigraph.py to read & write this new data
2) Updated hostcfgd to watch "KUBERNETES_MASTER" and call join/reset
   connection to master depending on if IP address is configured or not
3) Added helper scripts kube_join.sh & kube_reset.sh for join/reset respectively
1) Dropped oneshot
2) Take a lock, to avoid concurrent invocations
3) Keep Cron job until connected.
Copy link
Collaborator

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

files/image_config/kubernetes/scripts/kube_join.sh Outdated Show resolved Hide resolved
files/image_config/kubernetes/scripts/kube_join.sh Outdated Show resolved Hide resolved
files/image_config/kubernetes/scripts/kube_join.sh Outdated Show resolved Hide resolved
1) Dropped insecure
2) Finer tweaks
@lgtm-com
Copy link

lgtm-com bot commented Apr 24, 2020

This pull request introduces 1 alert when merging 46ce50f into 4adf243 - view on LGTM.com

new alerts:

  • 1 for Unused argument in a formatting call

@renukamanavalan
Copy link
Contributor Author

retest vs please.

@renukamanavalan
Copy link
Contributor Author

retest vsimage please.

Improved nodename to contain SONiC version, to distinguish.
During reset, drain & delete node, to enable join later.
@qiluo-msft qiluo-msft dismissed their stale review June 5, 2020 22:12

Unblocked, one issue remain

@renukamanavalan
Copy link
Contributor Author

renukamanavalan commented Jun 28, 2020

Writing kube commands as python package. A sonic-utilities PR #962 is under review. An updated new PR will be raised for build image. Hence closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants