Business Scenario
Exercise Options
Platform Simulation
Live Environment
Prerequisites
Task 1: Create a deployment via the Kyma Dashboard
Steps
Create a deployment via the Kyma Dashboard.
Open the Kyma Dashboard, navigate to the deployments workload view and choose the Create Deployment button.
Specify the deployment name and the container image. Use the following data:
Field | Value |
---|
Name | hello-kyma |
Container image | ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:1.0.0 |
As name enter hello-kyma
, as container image enter ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:1.0.0
Choose the YAML tab to review your deployment manifest and choose the Create button.
Verify the created deployment.
After the deployment has been created, it will be automatically redirected to the deployment details view. You can see the deployment details and the pod details.
Scroll down to the Resource Graph to observe the created deployment and its managed ReplicaSet and Pod.
Task 2: Update and apply the deployment manifest via kubectl
Steps
List your deployments.
Use kubectl
to list your deployments.
You should see the deployment you just created.
Get the deployment manifest as YAML and open it.
Note
Although you can use the Kyma Dashboard to edit the deployment manifest, we will use kubectl
to apply changes from a persisted file because it is highly recommended to put all manifests under version control. This is not possible with the Kyma Dashboard. Therefore, we will use kubectl
to download the deployment manifest and edit it locally.
Enter:
1
kubectl get deployment hello-kyma -o yaml >> hello-kyma-deployoment.yaml
If you open this file, you will see a lot of information in the manifest. Most of them are read-only fields, which the Kubernetes environment automatically sets.
Update the deployment to use a new version of the application.
Change the current container image to the new version and set a change-cause
to document the change.
ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:1.0.0
kubernetes.io/change-cause: "Upgrade to new release v1.0.1"
Save the file.
Apply the updated deployment manifest.
1
kubectl apply -f hello-kyma-deployment.yaml
Verify the update in the rollout history or with kubectl describe
1
kubectl rollout history deployment hello-kyma
1
kubectl describe deployment hello-kyma
Verify the updated deployment in the Kyma Dashboard.
Task 3: Scale the deployment via kubectl
Steps
Scale the deployment to three replicas.
1
kubectl scale deployment hello-kyma --replicas=3
Use the given command.
Verify it via kubectl
.
Kubernetes will now create the two additional pods.
Note
After a short while, there will be three pods running.
Verify it via the Kyma Dashboard.
Navigate to the Deployments workload view and select the hello-kyma
deployment. Scroll down to the list with pods.
Task 4: Perform a rollback of the deployment via kubectl
Imagine that you have deployed a new application version, but it is not working as expected. You can now roll back the deployment to the previous version.
Steps
List the rollout history.
Use:
1
kubectl rollout history deployment hello-kyma
You should see the two versions of the deployment.
Roll back the deployment by specifying the revision number.
Use:
1
kubectl rollout undo deployment hello-kyma --to-revision=1
You should see the following output:
1
deployment.apps/hello-kyma rolled back
List the rollout history again to verify the rollback.
Use:
1
kubectl rollout history deployment hello-kyma
You should see that the rollback was successful. Furthermore, the order of the revisions has changed, and it got incremented by one.
Result
Congratulations! You have completed the exercise. You have learned how to create, update, scale and roll back a deployment.