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
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
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-one.yaml --namespace customer-namespaces
# look at your pods
kubectl get pods -n customer-namespaces
# NAME READY STATUS RESTARTS AGE
# aks-helloworld-one-56c7b8d79d-sm4c6 2/2 Running 0 10m
Expose the application
The second file deploys a kubernetes Ingress object that binds the application to a DNS domain: e.g. hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io.
Use the command:
kubectl apply -f hello-world-ingress.yaml --namespace customer-namespaces
Now, open a browser and consult your first application: e.g. https://hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io or in a shell:
curl -k https://hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io
If you are not sure of your hostname you can run this command:
kubectl get ingress -n dev
Once your ingress is deployed, it might take some time before an IP is allocated and DNS configured. Wait a couple of minutes, then you can test with host
or nslookup
e.g.
host hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io
nslookup hw-ingress-rbo-sandbox.demo.eu.k8saas.thalesdigital.io
Remove your test
kubectl delete -f aks-helloworld-one.yaml --namespace customer-namespaces
kubectl delete -f hello-world-ingress.yaml --namespace customer-namespaces