Version: v1.1

Deploy First Application

Welcome to KubeVela! In this guide, we’ll walk you through how to install KubeVela, and deploy your first simple application.

Installation

Make sure you have finished and verified KubeVela installation following this guide.

A Simple Application

A simple deployment definition in KubeVela looks as below:

  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: crccheck/hello-world
  11. port: 8000
  12. traits:
  13. - type: ingress-1-20
  14. properties:
  15. domain: testsvc.example.com
  16. http:
  17. "/": 8000

Now deploy it to KubeVela:

  1. kubectl apply -f https://raw.githubusercontent.com/oam-dev/kubevela/master/docs/examples/vela-app.yaml

This command will deploy a web service component to target environment, which in our case is the Kubernetes cluster that KubeVela itself is installed.

After deployed, you can now directly visit this application as it already attached with a ingress trait (assume your cluster has Ingress enabled).

  1. $ curl -H "Host:testsvc.example.com" http://<some ip address>/
  2. <xmp>
  3. Hello World
  4. ## .
  5. ## ## ## ==
  6. ## ## ## ## ## ===
  7. /""""""""""""""""\___/ ===
  8. ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
  9. \______ o _,/
  10. \ \ _,'
  11. `'--.._\..--''
  12. </xmp>

Deploy More Components

KubeVela allows you to deploy diverse components types. In above example, the Web Service component is actually a predefined CUE module.

You can also try:

Helm components

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: app-delivering-chart
  5. spec:
  6. components:
  7. - name: redis-comp
  8. type: helm
  9. properties:
  10. chart: redis-cluster
  11. version: 6.2.7
  12. url: https://charts.bitnami.com/bitnami
  13. repoType: helm

Terraform components

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: rds-cloud-source
  5. spec:
  6. components:
  7. - name: sample-db
  8. type: alibaba-rds
  9. properties:
  10. instance_name: sample-db
  11. account_name: oamtest
  12. password: U34rfwefwefffaked
  13. writeConnectionSecretToRef:
  14. name: db-conn

Components from Git repository

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: git-app
  5. spec:
  6. components:
  7. - name: git-comp
  8. type: kustomize
  9. properties:
  10. repoType: git
  11. url: https://github.com/<path>/<to>/<repo>
  12. git:
  13. branch: master
  14. path: ./app/dev/

… and many many more. Please check the Deploying Components section under User Manuals for all supported types, and even go ahead to add your own.

Attach Operational Behaviors

KubeVela is not just about deploy. It allows you to attach predefined operational behaviors (named Traits) to your components in-place. For example, let’s assign a batch rollout strategy to our web service:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: rollout-trait-test
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. externalRevision: express-server-v1
  10. properties:
  11. image: stefanprodan/podinfo:4.0.3
  12. traits:
  13. - type: rollout
  14. properties:
  15. targetSize: 5
  16. rolloutBatches:
  17. - replicas: 2
  18. - replicas: 3

Now whenever the image version is updated in above YAML file, the express-server component will rollout following strategy defined in rolloutBatches.

For all supported traits in KubeVela, please check Attaching Traits section under User Manuals. Not surprisingly, you can also add your own traits to KubeVela with just minimal effort.

Define Policies and Workflow

Components and traits are just the beginning of your vela sail. KubeVela is by design a full functional Continuous Delivery (CD) platform with fine grained support for hybrid/multi-cloud/multi-cluster deployment.

Let’s say:

I want to deploy an micro-services application with two components, firstly to staging cluster with only 1 instance, then pause and wait for manual approval. If approved, then deploy it to production cluster but with instances scaled to 3.

Oops, imagine how many add-hoc scripts and glue code are needed in your CI/CD pipeline to achieve automation and deployment success rate in above process.

While with KubeVela, above process can be easily modeled as a declarative deployment plan as below:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: example-app
  5. namespace: default
  6. spec:
  7. components:
  8. - name: hello-world-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: scaler
  15. properties:
  16. replicas: 1
  17. - name: data-worker
  18. type: worker
  19. properties:
  20. image: busybox
  21. cmd:
  22. - sleep
  23. - '1000000'
  24. policies:
  25. - name: example-multi-env-policy
  26. type: env-binding
  27. properties:
  28. envs:
  29. - name: staging
  30. placement: # selecting the cluster to deploy to
  31. clusterSelector:
  32. name: cluster-staging
  33. selector: # selecting which component to use
  34. components:
  35. - hello-world-server
  36. - name: prod
  37. placement:
  38. clusterSelector:
  39. name: cluster-prod
  40. patch: # overlay patch on above components
  41. components:
  42. - name: hello-world-server
  43. type: webservice
  44. traits:
  45. - type: scaler
  46. properties:
  47. replicas: 3
  48. - name: health-policy-demo
  49. type: health
  50. properties:
  51. probeInterval: 5
  52. probeTimeout: 10
  53. workflow:
  54. steps:
  55. # deploy to staging env
  56. - name: deploy-staging
  57. type: deploy2env
  58. properties:
  59. policy: example-multi-env-policy
  60. env: staging
  61. # manual check
  62. - name: manual-approval
  63. type: suspend
  64. # deploy to prod env
  65. - name: deploy-prod
  66. type: deploy2env
  67. properties:
  68. policy: example-multi-env-policy
  69. env: prod

No more add-hoc scripts or glue code, KubeVela will get the application delivery workflow done with full automation and determinism. Most importantly, KubeVela expects you keep using the CI solutions you are already familiar with and KubeVela is fully complementary to them as the CD control plane.

For using KubeVela with your own CI pipelines and other tools, please check Best Practices section in the sidebar for more real world examples.

What’s Next

All above features are just the first glance of KubeVela. For next steps, we recommend: