kubectl, helm, and Orka

How to use kubectl and helm to tap into the underlying Kubernetes layer of Orka.

On this page, you will learn how to:

  • Check if you're connected to the cluster and that helm is configured properly.
  • Use kubectl to deploy a service to all nodes and look at the load balancer behavior.
  • Install a helm chart.

📘

Quick command summary

kubectl config view
helm env
helm repo [list / add]
kubectl create -f \*.yaml [\*.yaml must exist on your path]
kubectl get all
kubectl describe
helm install NAME REPO
helm list

Before you begin

Install kubectl and helm and create an Orka kube account. See Tapping into Kubernetes.

Familiarize yourself with the limitations imposed on your cluster. See Kubernetes Limitations in Orka.

Step 1: Verify that you're connected to the cluster

  1. Run a kubectl configuration check.
kubectl config view

If configured properly, you will see a similar output:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://10.10.10.99:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: sandbox
    user: mykubeuser
  name: [email protected]
current-context: [email protected]
kind: Config
preferences: {}
users:
- name: mykubeuser
  user:
    token: eyJhbGciOiJSUz...

If the configuration is empty instead, check Tapping into Kubernetes.

  1. Run a helm version and configuration check.
helm version

helm env

You must run Helm 3.

HELM_NAMESPACE should be set to sandbox instead of empty or kube-system.

  1. Check if you've added the helm repos.
helm repo list

If the list is empty, you need to add some helm repos with helm repo add. For example: helm repo add stable https://kubernetes-charts.storage.googleapis.com/

Step 2: Use kubectl to deploy a service

  1. Create a simple hello-kubernetes.yaml file in the current working directory of your terminal.
# hello-kubernetes.yaml
apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes
spec:
  externalIPs:
  - 10.10.12.5
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: hello-kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes
  template:
    metadata:
      labels:
        app: hello-kubernetes
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.5
        ports:
        - containerPort: 8080
      securityContext:
        runAsUser: 1000
  1. Create the service and the pods.
kubectl create -f hello-kubernetes.yaml
  1. Verify the deployment.
kubectl get all

You should see a similar output:

NAME                                    READY   STATUS    RESTARTS   AGE
pod/hello-kubernetes-676f8cf4c4-5nms6   1/1     Running   0          8s
pod/hello-kubernetes-676f8cf4c4-5xznz   1/1     Running   0          8s
pod/hello-kubernetes-676f8cf4c4-g42w2   1/1     Running   0          8s

NAME                       TYPE           CLUSTER-IP      EXTERNAL-IP              PORT(S)        AGE
service/hello-kubernetes   LoadBalancer   10.101.35.135   10.10.10.93,10.10.12.5   80:32409/TCP   10s

NAME                               READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/hello-kubernetes   3/3     3            3           9s

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/hello-kubernetes-676f8cf4c4   3         3         3       9s
  1. Check the replica distribution. The expected behavior is for each replica to occupy a separate node.
kubectl describe pods | grep Node

You should see a similar output:

Node:           macpro-3/10.10.10.6
Node-Selectors:  <none>
Node:           macpro-1/10.10.10.4
Node-Selectors:  <none>
Node:           macpro-2/10.10.10.5
Node-Selectors:  <none>

Step 3: Use helm

  1. Install a helm chart that works within the scope of your RBAC access to the cluster (see Limitations) and that is compatible with the Kubernetes version of your environment.
    For example: cerebro.
helm install cerebro stable/cerebro
  1. Check your chart.
helm list

kubectl get all

You should see a similar output:

NAME    NAMESPACE   REVISION    UPDATED                                 STATUS      CHART           APP VERSION
cerebro sandbox     1           2020-02-21 18:33:42.209952 +0200 EET    deployed    cerebro-1.3.1   0.8.5   

---

NAME                           READY   STATUS    RESTARTS   AGE
pod/cerebro-868cf95bbf-99kx2   0/1     Running   0          14s

NAME              TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
service/cerebro   ClusterIP   10.98.27.91   <none>        80/TCP    14s

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/cerebro   0/1     1            0           14s

NAME                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/cerebro-868cf95bbf   1         1         0       15s

What's next

Explore other Kubernetes operations within the limits of the RBAC configuration of your cluster.


Did this page help you?