Version: v1.0

Web Service

Description

Describes long-running, scalable, containerized services that have a stable network endpoint to receive external network traffic from customers.

Samples

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: website
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: oamdev/testapp:v1
  11. cmd: ["node", "server.js"]
  12. port: 8080
  13. cpu: "0.1"
  14. env:
  15. - name: FOO
  16. value: bar
  17. - name: FOO
  18. valueFrom:
  19. secretKeyRef:
  20. name: bar
  21. key: bar

Declare Volumes

The Web Service component exposes configurations for certain volume types including PersistenVolumeClaim, ConfigMap, Secret, and EmptyDir.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: website
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: nginx
  11. volumes:
  12. - name: "my-pvc"
  13. mountPath: "/var/www/html1"
  14. type: "pvc" # PersistenVolumeClaim volume
  15. claimName: "myclaim"
  16. - name: "my-cm"
  17. mountPath: "/var/www/html2"
  18. type: "configMap" # ConfigMap volume (specifying items)
  19. cmName: "myCmName"
  20. items:
  21. - key: "k1"
  22. path: "./a1"
  23. - key: "k2"
  24. path: "./a2"
  25. - name: "my-cm-noitems"
  26. mountPath: "/var/www/html22"
  27. type: "configMap" # ConfigMap volume (not specifying items)
  28. cmName: "myCmName2"
  29. - name: "mysecret"
  30. type: "secret" # Secret volume
  31. mountPath: "/var/www/html3"
  32. secretName: "mysecret"
  33. - name: "my-empty-dir"
  34. type: "emptyDir" # EmptyDir volume
  35. mountPath: "/var/www/html4"

Specification

  1. # Properties
  2. +------------------+----------------------------------------------------------------------------------+-----------------------+----------+---------+
  3. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  4. +------------------+----------------------------------------------------------------------------------+-----------------------+----------+---------+
  5. | cmd | Commands to run in the container | []string | false | |
  6. | env | Define arguments by using environment variables | [[]env](#env) | false | |
  7. | addRevisionLabel | | bool | true | false |
  8. | image | Which image would you like to use for your service | string | true | |
  9. | port | Which port do you want customer traffic sent to | int | true | 80 |
  10. | cpu | Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) | string | false | |
  11. | volumes | Declare volumes and volumeMounts | [[]volumes](#volumes) | false | |
  12. +------------------+----------------------------------------------------------------------------------+-----------------------+----------+---------+
  13. ##### volumes
  14. +-----------+---------------------------------------------------------------------+--------+----------+---------+
  15. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  16. +-----------+---------------------------------------------------------------------+--------+----------+---------+
  17. | name | | string | true | |
  18. | mountPath | | string | true | |
  19. | type | Specify volume type, options: "pvc","configMap","secret","emptyDir" | string | true | |
  20. +-----------+---------------------------------------------------------------------+--------+----------+---------+
  21. ## env
  22. +-----------+-----------------------------------------------------------+-------------------------+----------+---------+
  23. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  24. +-----------+-----------------------------------------------------------+-------------------------+----------+---------+
  25. | name | Environment variable name | string | true | |
  26. | value | The value of the environment variable | string | false | |
  27. | valueFrom | Specifies a source the value of this var should come from | [valueFrom](#valueFrom) | false | |
  28. +-----------+-----------------------------------------------------------+-------------------------+----------+---------+
  29. ### valueFrom
  30. +--------------+--------------------------------------------------+-------------------------------+----------+---------+
  31. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  32. +--------------+--------------------------------------------------+-------------------------------+----------+---------+
  33. | secretKeyRef | Selects a key of a secret in the pod's namespace | [secretKeyRef](#secretKeyRef) | true | |
  34. +--------------+--------------------------------------------------+-------------------------------+----------+---------+
  35. #### secretKeyRef
  36. +------+------------------------------------------------------------------+--------+----------+---------+
  37. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  38. +------+------------------------------------------------------------------+--------+----------+---------+
  39. | name | The name of the secret in the pod's namespace to select from | string | true | |
  40. | key | The key of the secret to select from. Must be a valid secret key | string | true | |
  41. +------+------------------------------------------------------------------+--------+----------+---------+