Version: v1.2

Kustomize

Create a Kustomize Component, it could be from Git Repo or OSS bucket or image registry.

Watch Files

Deploy From OSS bucket

KubeVela’s kustomize component meets the needs of users to directly connect Yaml files and folders as component products. No matter whether your Yaml file/folder is stored in a Git Repo or an OSS bucket, KubeVela can read and deliver it.

Let’s take the YAML folder component from the OSS bucket registry as an example to explain the usage. In the Application this time, I hope to deliver a component named bucket-comp. The deployment file corresponding to the component is stored in the cloud storage OSS bucket, and the corresponding bucket name is definition-registry. kustomize.yaml comes from this address of oss-cn-beijing.aliyuncs.com and the path is ./app/prod/.

  1. (Optional) If your OSS bucket needs identity verification, create a Secret:
  1. $ kubectl create secret generic bucket-secret --from-literal=accesskey=<your-ak> --from-literal=secretkey=<your-sk>
  2. secret/bucket-secret created
  1. Deploy it:
  1. cat <<EOF | vela up -f -
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: bucket-app
  6. spec:
  7. components:
  8. - name: bucket-comp
  9. type: kustomize
  10. properties:
  11. repoType: oss
  12. # If the bucket is private, you will need to provide
  13. secretRef: bucket-secret
  14. url: oss-cn-beijing.aliyuncs.com
  15. oss:
  16. bucketName: definition-registry
  17. path: ./app/prod/
  18. EOF

Please copy the above code block and deploy it directly to the runtime cluster:

  1. application.core.oam.dev/bucket-app created

Finally, we use vela ls to view the application status after successful delivery:

  1. vela ls
  2. APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
  3. bucket-app bucket-comp kustomize running healthy 2021-08-28 18:53:14 +0800 CST

The PHASE of the app is running, and the STATUS is healthy. Successful application deployment!

Attributes

ParametersDescriptionExample
repoTyperequired, The value of the Git. To indicate that kustomize configuration comes from the Git repositoryoss
pullIntervaloptional, Synchronize with Git repository, and the time interval between tuning helm release. The default value is 5m (5 minutes)10m
urlrequired, bucket’s endpoint, no need to fill in with schemeoss-cn-beijing.aliyuncs.com
secretRefoptional, Save the name of a Secret, which is the credential to read the bucket. Secret contains accesskey and secretkey fieldssec-name
timeoutoptional, The timeout period of the download operation, the default is 20s60s
pathrequired, The directory containing the kustomization.yaml file, or the directory containing a set of YAML files (used to generate kustomization.yaml)./prod
oss.bucketNamerequired, bucket nameyour-bucket
oss.provideroptional, Generic or aws, if you get the certificate from aws EC2, fill in aws. The default is generic.generic
oss.regionoptional, bucket region

Deploy From Git Repo

ParametersDescriptionExample
repoTyperequired, The value of the Git. To indicate that kustomize configuration comes from the Git repositorygit
pullIntervaloptional, Synchronize with Git repository, and the time interval between tuning helm release. The default value is 5m (5 minutes)10m
urlrequired, Git repository addresshttps://github.com/oam-dev/terraform-controller
secretRefoptional, The Secret object name that holds the credentials required to pull the Git repository. The username and password fields must be included in the HTTP/S basic authentication Secret. For SSH authentication, the identity, identity.pub and known_hosts fields must be includedsec-name
timeoutoptional, The timeout period of the download operation, the default is 20s60s
git.branchoptional, Git branch, master by defaultdev
git.provideroptional, Determines which git client library to use. Defaults to GitHub, it will pick go-git. AzureDevOps will pick libgit2GitHub

How-to

  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. provider: GitHub
  15. path: ./app/dev/

Override Kustomize

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: bucket-app
  5. spec:
  6. components:
  7. - name: bucket-comp
  8. type: kustomize
  9. properties:
  10. # ...omitted for brevity
  11. path: ./app/

Watch Image Registry

ParameterRequiredDescriptionExample
imagerequiredThe image urloamdev/vela-core
secretRefoptionalIf it’s a private image registry, use kubectl create secret docker-registry to create the secretmy-secret
policy.alphabetical.orderoptionalOrder specifies the sorting order of the tags. Given the letters of the alphabet as tags, ascending order would select Z, and descending order would select Aasc
policy.numerical.orderoptionalGiven the integer values from 0 to 9 as tags, ascending order would select 9, and descending order would select 0asc
policy.semver.rangeoptionalRange gives a semver range for the image tag; the highest version within the range that’s a tag yields the latest image‘>=1.0.0 <2.0.0’
filterTags.extractoptionalExtract allows a capture group to be extracted from the specified regular expression pattern, useful before tag evaluation$timestamp
filterTags.patternoptionalPattern specifies a regular expression pattern used to filter for image tags‘^master-[a-f0-9]’
commitMessageoptionalUse for more commit message‘Image: {{range .Updated.Images}}{{println .}}{{end}}’

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: image-app
  5. spec:
  6. components:
  7. - name: image
  8. type: kustomize
  9. properties:
  10. imageRepository:
  11. image: <your image>
  12. secretRef: imagesecret
  13. filterTags:
  14. pattern: '^master-[a-f0-9]+-(?P<ts>[0-9]+)'
  15. extract: '$ts'
  16. policy:
  17. numerical:
  18. order: asc
  19. commitMessage: "Image: {{range .Updated.Images}}{{println .}}{{end}}"