Version: v1.3

Deploy First Application

Before starting, please confirm that you’ve installed KubeVela and enabled the VelaUX addon according to the installation guide.

Welcome to KubeVela! This section will guide you to deliver your first app.

Below is a classic KubeVela application which contains one component with one operational trait, basically, it means to deploy a container image as webservice with one replica. Additionally, there are three policies and workflow steps, it means to deploy the application into two different environments with a bit different configurations.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-app
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: oamdev/hello-world
  11. ports:
  12. - port: 8000
  13. expose: true
  14. traits:
  15. - type: scaler
  16. properties:
  17. replicas: 1
  18. policies:
  19. - name: target-default
  20. type: topology
  21. properties:
  22. # The cluster with name local is installed the KubeVela.
  23. clusters: ["local"]
  24. namespace: "default"
  25. - name: target-prod
  26. type: topology
  27. properties:
  28. clusters: ["local"]
  29. # This namespace must be created before deploying.
  30. namespace: "prod"
  31. - name: deploy-ha
  32. type: override
  33. properties:
  34. components:
  35. - type: webservice
  36. traits:
  37. - type: scaler
  38. properties:
  39. replicas: 2
  40. workflow:
  41. steps:
  42. - name: deploy2default
  43. type: deploy
  44. properties:
  45. policies: ["target-default"]
  46. - name: manual-approval
  47. type: suspend
  48. - name: deploy2prod
  49. type: deploy
  50. properties:
  51. policies: ["target-prod", "deploy-ha"]
  • Create an environment for your first app.
  1. # This command will create a namespace in the local cluster
  2. $ vela env init prod --namespace prod
  3. environment prod with namespace prod created
  • Starting deploy the application
  1. $ vela up -f https://kubevela.net/example/applications/first-app.yaml
  2. Applying an application in vela K8s object format...
  3. I0516 15:45:18.123356 27156 apply.go:107] "creating object" name="first-vela-app" resource="core.oam.dev/v1beta1, Kind=Application"
  4. App has been deployed 🚀🚀🚀
  5. Port forward: vela port-forward first-vela-app
  6. SSH: vela exec first-vela-app
  7. Logging: vela logs first-vela-app
  8. App status: vela status first-vela-app
  9. Endpoint: vela status first-vela-app --endpoint
  10. Application prod/first-vela-app applied.
  • View the process and status of the application deploy
  1. $ vela status first-vela-app
  2. About:
  3. Name: first-vela-app
  4. Namespace: prod
  5. Created at: 2022-05-16 15:45:18 +0800 CST
  6. Status: workflowSuspending
  7. Workflow:
  8. ...
  9. Services:
  10. - Name: express-server
  11. Cluster: local Namespace: default
  12. Type: webservice
  13. Healthy Ready:1/1
  14. Traits:
  15. scaler

The application will become a workflowSuspending status, it means the workflow has finished the first two steps and waiting for manuel approval as the step specified.

  • Access the application

We can check the application by:

  1. vela port-forward first-vela-app 8000:8000

It will invoke your browser and your can see the website:

  1. <xmp>
  2. Hello KubeVela! Make shipping applications more enjoyable.
  3. ...snip...
  • Resume the workflow

After we finished check the application, we can approve the workflow to continue:

  1. $ vela workflow resume first-vela-app
  2. Successfully resume workflow: first-vela-app

Then the rest part will be delivered in prod namespace:

  1. $ vela status first-vela-app
  2. About:
  3. Name: first-vela-app
  4. Namespace: prod
  5. Created at: 2022-05-16 15:45:18 +0800 CST
  6. Status: running
  7. Workflow:
  8. ...snipt...
  9. Services:
  10. - Name: express-server
  11. Cluster: local Namespace: prod
  12. Type: webservice
  13. Healthy Ready:2/2
  14. Traits:
  15. scaler
  16. - Name: express-server
  17. Cluster: local Namespace: default
  18. Type: webservice
  19. Healthy Ready:1/1
  20. Traits:
  21. scaler

Great! You have finished deploying your first KubeVela application, you can also view and manage it in UI.

Currently, the application created by CLI is readonly in your dashboard.

After finished the installation of VelaUX, you can view and manage the application created.

  • Port forward the UI if you don’t have endpoint for access:
  1. vela port-forward addon-velaux -n vela-system 8080:80
  • Check the password by:
  1. vela logs -n vela-system --name apiserver addon-velaux | grep "initialized admin username"
  • Check the resources deployed

Click the application card, then you can view the details of the application.

Deploy First Application - 图1

  1. $ vela delete first-vela-app
  2. Deleting Application "first-vela-app"
  3. app "first-vela-app" deleted from namespace "prod"

That’s it! You succeed at the first application delivery. Congratulation!

  • View Core Concepts to learn more about how it works.
  • View User Guide to look on more of what you can achieve with KubeVela.

Last updated on Nov 1, 2022 by Tianxin Dong