Tutorial - Deploy your first application
Objectives
This tutorial guides you step by step to perform your first deployment on a Managed Kubernetes cluster. By the end of this guide, you will have:
- Deployed a simple web application.
- Exposed this application within the cluster via a Service.
- Made the application accessible from the Internet via an Ingress.
Prerequisites
- You have configured your cluster access as described in the quickstart guide.
- You have a namespace with deployment permissions. In this tutorial, we will use a namespace named
hello-world.
Step 1: Create a namespace
If not already done, create a namespace to isolate your application.
kubectl create namespace hello-world
Step 2: Deploy a "Hello World" application
We will deploy a demonstration application that displays a simple web page.
-
Create a file named
deployment.yamlwith the following content:apiVersion: apps/v1kind: Deploymentmetadata:name: hello-world-deploymentnamespace: hello-worldlabels:app: hello-worldspec:replicas: 2selector:matchLabels:app: hello-worldtemplate:metadata:labels:app: hello-worldspec:containers:- name: hello-worldimage: nginxdemos/hello:plain-textports:- containerPort: 80 -
Apply this manifest to your cluster:
kubectl apply -f deployment.yaml -
Verify that the deployment was created and that the pods are running:
kubectl get deployment -n hello-world# Vous devriez voir votre déploiement avec 2/2 replicas prêts.NAME READY UP-TO-DATE AVAILABLE AGEhello-world-deployment 2/2 2 2 102skubectl get pods -n hello-world# Vous devriez voir deux pods avec le statut "Running".NAME READY STATUS RESTARTS AGEhello-world-deployment-669dfbd799-294zz 1/1 Running 0 2m21shello-world-deployment-669dfbd799-plcbg 1/1 Running 0 2m21s
Step 3: Expose the application in the cluster (Service)
To allow the different components of the cluster to communicate with our application, we need to create a Service.
-
Create a file named
service.yaml:apiVersion: v1kind: Servicemetadata:name: hello-world-servicenamespace: hello-worldspec:selector:app: hello-worldports:- protocol: TCPport: 80targetPort: 80type: ClusterIP -
Apply the manifest:
kubectl apply -f service.yamlYour application is now accessible via the name
hello-world-service.hello-worldfrom any other pod in the cluster.
Step 4: Make the application accessible from the Internet (Ingress)
To expose our service to the Internet, we will use an Ingress resource. The Managed Kubernetes offering provides several preconfigured ingressClassNames. We will use nginx-external for public exposure.
-
Create a file
ingress.yaml. Remember to replacevotre-cluster-idwith your cluster's identifier (e.g.,ctodev).apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: hello-world-ingressnamespace: hello-worldspec:ingressClassName: nginx-externalrules:- host: "hello-world.external.votre-cluster-id.mk.ms-cloud-temple.com" # changez moihttp:paths:- path: /pathType: Prefixbackend:service:name: hello-world-serviceport:number: 80 -
Apply the manifest:
kubectl apply -f ingress.yaml
Step 5: Verify Access
A DNS entry "*" already points all URLs ending with ".external.votre-cluster-id.mk.ms-cloud-temple.com" to the IP of the "external" ingress. Applications published on this DNS suffix are therefore directly accessible.
curl http://hello-world.external.votre-cluster-id.mk.ms-cloud-temple.com
You should receive a response from the demo NGINX server.
StatusCode : 200
StatusDescription : OK
Content : Server address: 10.247.1.223:80
Server name: hello-world-deployment-669dfbd799-plcbg
Date: 29/Oct/2025:15:40:04 +0000
URI: /
Request ID: 2df985e0630c3a123b5cde23b687a033
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 170
Cache-Control: no-cache
Content-Type: text/plain
Date: Wed, 29 Oct 2025 15:40:04 GMT
Expires: Wed, 29 Oct 2025 15:40:03 GMT
Server: ng...
:::warning[Going further: security in production ] This tutorial has shown you the basics of deployment. For a production environment, it is crucial to apply additional security measures:
- Use secure images : Prefer images from your secure enterprise registry such as Harbor rather than public images.
- Control network traffic : Set up
NetworkPoliciesto restrict communications to only the necessary traffic between your applications. - Apply governance policies : Use tools like Kyverno to enforce security rules (e.g., forbid "root" containers, require resource
requestsandlimits, etc.). :::
Cleanup
To delete all the resources you created during this tutorial, you can simply delete the namespace:
kubectl delete namespace hello-world
Congratulations, you have deployed and exposed your first application on Managed Kubernetes!