Connect to the Server

  1. Run the following command, where -L mean to forward server's port to local. Because Kubernetes exposes port 6445, we would like to forward it to localhost:6443. The username should just be your Cornell NetID (it's easier to memorize). An admin account holder should be able to create the linux account for you.

    ssh -i -L 6445:localhost:6443 username@ssh.diaper-project.com 

  2. You should see a pop-up looks like this, which means that you have already connected to the server. 

Connect to Kubernetes

  1. We first need to install Kubernetes on our local machine. To install using Docker (you might want to use Docker to build images), check out Install and turn on Kubernetes.
  2. There are various UI explorers for Kubernetes, one of my favorites is called k9s. To install, check out Install (k9scli.io).
  3. Add the server cluster credentials in the Kubernetes config file. The configuration is as follows:
    Kubernetes Config File
    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz756SXpNRFl3SGhjTk1qUXdNakExTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7RRMgpXakFqTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz71WeUxXTmhRREUzTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7BRSUJCZ2dxaGtqT1BRTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7NqNkNIdDlxK3daSUV6N093ajM5VXJmRnoKTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7dTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz70JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz72CnNrWkUzOG93Q2dZSUtvWkl6ajBFQXdJRFNRQXdSZ0loQUxKelRCZTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7KQVkya1cyamcvMy80QWlFQXdhMTlENk1IcThPTTrEPCPrqR3YziyHVBJnibzUcQvxyeVaz7UzdFJvY2c9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
        server: https://127.0.0.1:6445
      name: diaper-server
    contexts:
    - context:
        cluster: diaper-server
        user: <Kubernetes service account name>
      name: diaper-server
    current-context: diaper-server
    kind: Config
    preferences: {}
    users:
    - name: <Kubernetes service account name>
      user:
        token: <Kubernetes service account token>
  4. After adding the configs, you should be able to connect to the Kubernetes cluster using k9s. If your k9s is under one of the environments $PATH, you can simply run: k9s on any command line interface. It looks like the following:

    If you don't see all pods running, it is probably because you're viewing a specific namespace. You can simply press '0' to view pods in all namespaces.
  5. To navigate between Services, Deployments, or Pods, you can type 
    :services       or       :deployments       or       :pods
  6. To port-forward a pod, type shift+F.  To view the log, type l. To kill a pod, type ctrl+k.... You can always view these commands by typing ?(question mark).

More k9s Tutorial: derailed/k9s: 🐶 Kubernetes CLI To Manage Your Clusters In Style! (github.com)

  • No labels