Skip to main content

Simplest hello world

Easy-to-do tutorial to get started in no time !

Prerequisites

To run this onboarding tutorial, we should first have:

  • a k8saas cluster deployed
info

To ask and set up your own cluster, look at the section Getting Started.

And downloaded the following files:

Tutorial

The application is a simple website, displaying a welcome page on port 80.

Get your credentials

note

The cluster name and the resource group name are the same within k8saas.

az aks get-credentials  --name "$K8SAAS_RESOURCE_NAME"  --resource-group "$K8SAAS_RESOURCE_NAME"
kubelogin convert-kubeconfig -l azurecli

Update DNS zone

You will need to update the file hello-world-ingress.yaml with the right DNS zone and at the same time we will change the host to be sure it's unique and not interfering with another project.

Look and replace:

spec:
ingressClassName: nginx
rules:
- host: hw-ingress-<VALUE_TO_CHANGE>.demo.<DNS_ZONE>
...
tls:
- hosts:
- hw-ingress-<VALUE_TO_CHANGE>.demo.<DNS_ZONE>

With the DNS zone information that was in the onboarding email sent to you. If you do not have this information you can always run this:

kubectl get ingress -n monitoring

It should return something like this:

NAME                          CLASS   HOSTS                                                             ADDRESS         PORTS     AGE
prometheus-operator-grafana nginx grafana.k8saas-rbo-sandbox.eu.k8saas.thalesdigital.io 20.50.218.145 80, 443 389d

Now with the information from the previous command, update hello-world-ingress.yaml with the right information. Here we've replaced hw-ingress-<VALUE_TO_CHANGE> with hw-ingress-rbo-sandbox to be unique like suggested earlier.

spec:
ingressClassName: nginx
rules:
- host: hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io
...
tls:
- hosts:
- hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io

Deploy the application

Deploy the application, composed of :

  • a kubernetes Deployment object: which spin up the application pod (container) and make sure it's up and running at all time;
  • a kubernetes Service object: which exposes the pod internally.

Using the following commands:

# this start a hello world pod
kubectl apply -f aks-helloworld-windows.yaml --namespace customer-namespaces
# look at your pods
kubectl get pods -n customer-namespaces
# NAME READY STATUS RESTARTS AGE
# aks-helloworld-windows-56c7b8d79d-sm4c6 1/1 Running 0 10m

Expose the application

The second file deploys a kubernetes Ingress object that binds the application to a DNS domain: hw-win-ingress.test.kaas.thalesdigital.io.

Use the command:

kubectl apply -f hello-world-ingress-windows.yaml --namespace customer-namespaces

Now, open a browser and consult your first application: https://hw-win-ingress.test.kaas.thalesdigital.io or in a shell:

curl -k https://hw-win-ingress.test.kaas.thalesdigital.io

Notes: It can take up to 5minutes before that url be reachable.

Remove your test

kubectl delete -f hello-world-windows.yaml --namespace customer-namespaces
kubectl delete -f hello-world-ingress-windows.yaml --namespace customer-namespaces