Kubevela FAQ - how do you inject env and secrets into your application?

To inject env or secret you need to make use of trait using a type call init-container.

https://kubevela.io/docs/end-user/traits/references/#init-container

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: simple-vela-app
spec:
  components:
    - name: express-server-1
      type: webservice
      properties:
        image: oamdev/hello-world
        ports:
         - port: 8000
           expose: true
        cpu: "1"
        memory: "120M"
      traits:
        - type: init-container
          properties:
              name: express-server-trait
              image: oamdev/hello-world
              cmd: ["echo", "hello"]
              initMountPath: /data
              appMountPath: /data-initialized
              env:
                - name: "test"
                  value: "myvalue"

                - name: "test2"
                  value: "myvalue2"

                - name: "secret"
                  valueFrom:
                    secretKeyRef:
                      name: empty-secret
                      key: key2

        - type: scaler
          properties:
            replicas: 1
        - type: cpuscaler
          properties:
            min: 1
            max: 10
            cpuUtil: 60
  policies:
    - name: target-default
      type: topology
      properties:
        # The cluster with name local is installed the KubeVela.
        clusters: ["local"]
        namespace: "default"
  workflow:
    steps:
      - name: deploy2default
        type: deploy
        properties:
          policies: ["target-default"]
      - name: manual-approval
        type: suspend
      - name: deploy2prod
        type: deploy
        # properties:
        #   policies: ["target-prod", "deploy-ha"]
 

We assume that you have the following keys in your secret called empty-secret

  kubectl create secret generic my-secret --from-literal=test
=supersecret --from-literal=test2=topsecret --from-literal=key2=topsecret




Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm