Giter VIP home page Giter VIP logo

add-ssh-key's Introduction

Add your SSH public key to all hosts of your cluster easily!

Adding a SSH key to all the hosts in the environment is tedious, this script makes it easy!

Example DaemonSet manifest file:

Follow the two steps in the following yaml file and launch it using "kubectl"

kubectl apply -f <filename>

daemonset-add-ssh-key.yaml

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: add-ssh-key
spec:
  selector:
    matchLabels:
      name: add-ssh-key
  template:
    metadata:
      labels:
        name: add-ssh-key
    spec:
      containers:
      - name: add-ssh-key
        image: leodotcloud/add-ssh-key
        imagePullPolicy: Always
        volumeMounts:
        - name: userhomedir
          mountPath: /tmp/user
        env:
          - name: SSH_KEY_TO_ADD
            value: "ssh-rsa blahblahblah [email protected]"    # Step 1: Replace the value with your SSH public key
      volumes:
      - name: userhomedir
        hostPath:
          path: /home/ubuntu    # Step 2: Replace this user home directory path accordingly

If you have isolated planes for etcd/controlplane, you might have to add tolerations to schedule the pods of the DaemonSet on those nodes.

daemonset-add-ssh-key-with-tolerations.yaml

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: add-ssh-key
spec:
  selector:
    matchLabels:
      name: add-ssh-key
  template:
    metadata:
      labels:
        name: add-ssh-key
    spec:
      containers:
      - name: add-ssh-key
        image: leodotcloud/add-ssh-key
        imagePullPolicy: Always
        volumeMounts:
        - name: userhomedir
          mountPath: /tmp/user
        env:
          - name: SSH_KEY_TO_ADD
            value: "ssh-rsa blahblahblah [email protected]"    # Step 1: Replace the value with your SSH public key
      volumes:
      - name: userhomedir
        hostPath:
          path: /home/ubuntu    # Step 2: Replace this user home directory path accordingly
      tolerations:
      - key: "node-role.kubernetes.io/controlplane"
        value: "true"
        operator: "Equal"
        effect: "NoSchedule"
      - key: "node-role.kubernetes.io/etcd"
        value: "true"
        operator: "Equal"
        effect: "NoExecute"

add-ssh-key's People

Contributors

leodotcloud avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.