Documentation

esc
    Kubernetes / Console guide

    Using Kubernetes through the Console

    Step-by-step walkthrough to set up a VPC subnet, create a managed Kubernetes cluster in the console, download its kubeconfig, open the Kubernetes Dashboard, and expose a workload to the internet.

    Overview

    The console creates and runs managed Kubernetes clusters. Every node of a cluster is a VM in your account, billed as a VM of the node plan, and the platform joins them into one cluster for you. The nodes appear as the cluster, not in your list of virtual machines.

    This guide walks you through:

    1. Setting up a VPC subnet for the cluster.
    2. Creating a cluster in the console.
    3. Downloading the kubeconfig and connecting with kubectl.
    4. Opening the Kubernetes Dashboard.
    5. Deploying a workload and exposing it to the internet.
    6. Running the cluster from its page.

    1. Prerequisites and network setup

    Step 1.1: Create a subnet for the cluster

    In a VPC zone the cluster's nodes live in a subnet of one of your VPCs.

    1. Choose VPCs in the sidebar.
    2. Open your VPC, or press Create VPC to make one.
    3. Under Subnets, press Add subnet.
    4. Enter a name (for example k8s-tier) and an address range inside the VPC's range, such as a /24 (written <subnet-cidr> below). Give the cluster a subnet of its own, with room for every node it could have; a /24 is plenty.
    5. Confirm.

    Step 1.2: Check the subnet's network ACL

    The subnet's network ACL applies to the cluster's nodes like any other VM in it. Open the subnet from the VPC's page to see its Network ACL.

    • Kubernetes API server: nothing to add. A public or dual cluster opens port 6443 on its subnet to its allow-list (or to any address when the list is empty) by itself, and closes it again when it goes private or is deleted. A deny rule of your own still applies first.
    • Services you expose: press Add rule and allow TCP to the service's NodePort (for the example below, 30088) from the addresses that should reach it, such as 0.0.0.0/0 (anywhere).

    The cluster needs no public IP of your own: a public or dual cluster gets an address of its own (see API server access).


    2. Create a cluster in the console

    Choose Kubernetes in the sidebar and press Create cluster. The form has four sections.

    2.1 Name and location

    • Name: 1 to 40 lowercase letters, digits and hyphens, starting with a letter and not ending with a hyphen (for example prod-cluster). Press Generate for a random memorable name. It must be unique in your organization.
    • Where it runs: Kubernetes in a VPC puts the nodes in a subnet of yours, in af-abj-2. Standalone Kubernetes runs them on the standard network, where offered.

    2.2 Kubernetes version

    Choose a version (for example v1.31.1). The newest is first. A cluster keeps the version it is created with; see versions and upgrades.

    2.3 Nodes

    • Node size: the plan every node uses, for example Developer (2 vCPU, 4 GB memory, 40 GB disk). Each option shows its monthly price per node. In af-abj-2 only the fixed node sizes are offered.
    • Control plane: 1 node, or 3 nodes (highly available) where the zone offers it. This is fixed once the cluster exists.
    • Workers: a fixed number from 1 to 10, or turn on Autoscaling and set Minimum workers and Maximum workers. The platform's autoscaler adds workers when pods are waiting for room and removes idle ones, based on your pods' resource requests. See autoscaling.

    2.4 Network (VPC zone)

    • VPC and Subnet: the subnet from step 1.1, shown as its name and range, for example k8s-tier (<subnet-cidr>).
    • The pod network plugin: Flannel (the default), WireGuard (traffic between nodes encrypted) or Calico (network policies). It is fixed once the cluster exists.
    • Where the API server can be reached from:
      • Private (VPC Only), the default: only from inside your VPC. The cluster has no public address.
      • Public: from the internet, on a public address of the cluster's own.
      • Dual: both.

    A public or dual cluster's address is billed as a static IP for every hour it holds it; the summary shows it as Public address and adds it to the monthly estimate. Its API server is on port 6443 of that address, and the services you expose are on it too. To reach the cluster with kubectl from your own computer, choose Public or Dual.

    With Public or Dual you can choose Restricted CIDRs and list the IPv4 ranges allowed to reach the API server (for example your office's range, <office-cidr>), or leave Any address (0.0.0.0/0). Traffic from inside your VPC always gets through.

    The summary shows the nodes you pay for and that there is no upfront payment. Press Create cluster. The cluster's page follows it from provisioning to running, which takes several minutes.

    A new cluster runs the Metrics Server and the storage driver add-ons; the ingress controller is off. Change them on the cluster's Add-ons tab (see 6.5).


    3. Download the kubeconfig and connect

    Once the cluster is running:

    1. On the cluster's Overview tab, find Connect with kubectl.
    2. Press Download kubeconfig. Only owners and admins can download it.
    3. Keep the file somewhere private, for example ~/.kube/config-prod.yaml.

    Configure kubectl

    Terminal
    $ chmod 600 ~/.kube/config-prod.yaml$ export KUBECONFIG=~/.kube/config-prod.yaml$ kubectl cluster-infoKubernetes control plane is running at https://<cluster-public-ip>:6443CoreDNS is running at https://<cluster-public-ip>:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

    Check the nodes:

    Terminal
    $ kubectl get nodesNAME                      STATUS   ROLES                  AGE   VERSIONprod-cluster-control-01   Ready    control-plane,master   10m   v1.31.1+k3s1prod-cluster-worker-01    Ready    <none>                 8m    v1.31.1+k3s1prod-cluster-worker-02    Ready    <none>                 8m    v1.31.1+k3s1

    Every node should be Ready. With -o wide, their internal addresses are in your subnet's range.


    4. Open the Kubernetes Dashboard

    The Kubernetes Dashboard is not installed in a new cluster. To use it, install it yourself, give it an admin login, and reach it through kubectl proxy.

    Step 4.1: Install the Dashboard

    Terminal
    $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

    Step 4.2: Create an admin login

    dashboard-admin.yaml
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: admin-user
      namespace: kubernetes-dashboard
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: admin-user
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin
    subjects:
    - kind: ServiceAccount
      name: admin-user
      namespace: kubernetes-dashboard

    Apply it and ask for a login token:

    Terminal
    $ kubectl apply -f dashboard-admin.yaml$ kubectl -n kubernetes-dashboard create token admin-usereyJhbGciOiJSUzI1NiIsImtpZCI6Ii4uLiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiw...

    The token gives full control of the cluster, and lasts an hour by default.

    Step 4.3: Open it in your browser

    Start a local proxy to the cluster's API, and keep it running:

    Terminal
    $ kubectl proxy --port=8001Starting to serve on 127.0.0.1:8001

    Then open:

    Code
    http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

    Choose Token, paste the token and press Sign in. The same commands are on the cluster's Workloads & Services tab.


    5. Deploy a workload and expose it to the internet

    Step 5.1: Deploy an application

    Two nginx pods behind a NodePort service:

    workloads.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: demo-web
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: demo-web
      template:
        metadata:
          labels:
            app: demo-web
        spec:
          affinity:
            podAntiAffinity:
              preferredDuringSchedulingIgnoredDuringExecution:
              - weight: 100
                podAffinityTerm:
                  labelSelector:
                    matchExpressions:
                    - key: app
                      operator: In
                      values:
                      - demo-web
                  topologyKey: kubernetes.io/hostname
          containers:
          - name: nginx
            image: nginx:alpine
            ports:
            - containerPort: 80
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: demo-web
      namespace: default
    spec:
      type: NodePort
      selector:
        app: demo-web
      ports:
      - port: 80
        targetPort: 80
        nodePort: 30088

    Apply it with kubectl, or paste it into In-Browser Manifest Runner & Linter on the cluster's Config & Runner tab and press Apply Manifest to Cluster:

    Terminal
    $ kubectl apply -f workloads.yamldeployment.apps/demo-web createdservice/demo-web created

    Check the pods:

    Terminal
    $ kubectl get pods -o wideNAME                        READY   STATUS    RESTARTS   AGE   IP           NODEdemo-web-779848f956-2qpx8   1/1     Running   0          30s   <pod-ip>     prod-cluster-worker-01demo-web-779848f956-k97wf   1/1     Running   0          30s   <pod-ip>     prod-cluster-worker-02

    The pod anti-affinity rule spreads the two replicas over different workers where it can.

    Step 5.2: Expose the service

    A public or dual cluster routes a public port of its own address to a service. Do it with the CLI (or the API's expose-service):

    Terminal
    $ pantech kubernetes expose prod-cluster demo-web --port 80

    The service keeps its NodePort (30088), gets the pantechdynamics.com/public-port annotation, and the route is created. Make sure the subnet's network ACL allows the NodePort (step 1.2). Port 22 and the cluster's API port cannot be used. A private cluster has no public address, so it cannot expose services.

    Step 5.3: Test it from the internet

    Use the cluster's public address from its Networking tab in place of <cluster-public-ip>:

    Terminal
    $ curl -I http://<cluster-public-ip>/HTTP/1.1 200 OKServer: nginxContent-Type: text/html

    kube-proxy sends each request to one of the pods.


    6. Run the cluster from its page

    The cluster's page has the tabs Overview, Workloads & Services, Config & Runner, Compute, Networking, Add-ons, Metrics and Settings.

    6.1 Workloads & Services

    • Public Network Routing & Port Forwarding shows the routes on the cluster's public address, starting with the Kubernetes API Server. Press Sync Public Routing after exposing or unexposing services with kubectl: routes to services that no longer carry the pantechdynamics.com/public-port annotation are removed.
    • Cluster Workload Inspection & Web Dashboard has the Dashboard commands from step 4 and a few kubectl commands to copy.

    6.2 Config & Runner

    • Cluster Kubeconfig: download the kubeconfig (owners and admins).
    • In-Browser Manifest Runner & Linter: paste YAML, choose the namespace for objects that have none, and press Apply Manifest to Cluster. It is applied with server-side apply, like kubectl apply --server-side, up to 512 KB and 100 objects. The editor checks the YAML before you apply it and explains what it creates.
    • Fetch Live State loads what runs in the cluster now (your Deployments, Services, ConfigMaps and the like, never Secrets) into the editor, so you can edit it and apply it back.

    6.3 Compute

    • Change nodes: a fixed number of workers from 1 to 10, or the autoscaler's range. Removed workers are drained first.
    • Resize node plan: move every node to another plan, one node at a time. See node plans and billing.
    • Node pools: Add node pool for workers with their own plan, labels and taints; Scale or Delete a pool. See node pools.

    6.4 Networking

    • Configure endpoint access: switch between Public, Private and Dual (Public & Private), and change the CIDRs allowed to reach the API server. Press Save configuration.
    • The pod network plugin and address ranges are shown here; they are fixed once the cluster exists.

    6.5 Add-ons

    Turn Metrics Server, Block Storage CSI (persistent volumes on the node's own disk, StorageClass local-path) or Ingress Controller (ingress-nginx, served on 80 and 443 of the cluster's public address) on or off. The status shows installing or removing until the cluster runs your choice. See add-ons.

    6.6 Metrics

    CPU and memory graphs for the cluster over the last 1 hour, 24 hours, 7 days or 30 days.

    6.7 Stop and start

    • Press Stop, then Stop cluster. Every node shuts down and nothing in the cluster runs; the nodes' disks and the cluster's volume storage are still billed.
    • Press Start, then Start cluster, to bring it back. Its nodes are billed for compute again once it runs.

    To delete the cluster, press Delete, then Delete cluster. See delete a cluster.

    Was this page helpful?

    Updated