Environments

Pipelines and data channels are deployed to Kubernetes in namespaces. Namespaces are exposed as environments.

Environmemts

Attributes are added to the Kubernetes namespace object as annotations and labels to describe the environment:

  • Environment Name: label environment
  • Environment Description: annotation description
  • Environment Color: annotation tag
  • Must be Published?: annotation publishedArtifactsOnly - true if only published artifacts can be deployed. false if artifacts from the sandbox space can be deployed.
  • Environment Predecessors: annotation predecessors - optional JSON list of predecessors

The values specified to describe an environment have these constraints:

  • The namespace name is restricted to characters supported by a DNS name.
  • The environment name is restricted to characters supported by a Kubernetes label.
  • The annotation values are restricted to characters support by a Kubernetes annotation.
  • The environment color tag value must be a case-insensitive valid HTML color name. If an invalid color name is specified the color White is used.

These kubectl commands are used to manage Kubernetes namespaces (see Share a Cluster with Namespaces for complete documentation):

  • kubectl apply --filename <file-name> - create or update a namespace
  • kubectl describe namespace <namespace-name> - display a namespace
  • kubectl delete namespaces <namespace-name> - remove a namespace

Note that if a deployed scoring flow or data channel uses any kubernetes Secrets, these secrets must also be created in the new namespace. Adding the elastic search secret is a minimal requirement.

Note: ensure that correct cluster context is set before executing any kubectl commands.

  1. kubectl config current-context
  2. kubectl config use-context <context-name>

The example below demonstrates creating, updating, displaying, and removing a namespace datachannels for environment Data-Channels:

  1. //
  2. // Create Data-Channels environment
  3. //
  4. $ kubectl apply -f - <<!
  5. kind: Namespace
  6. apiVersion: v1
  7. metadata:
  8. name: datachannels
  9. labels:
  10. environment: "Data-Channels"
  11. annotations:
  12. publishedArtifactsOnly: "true"
  13. description: "Data channel environment"
  14. predecessors: '["Development"]'
  15. tag: orange
  16. !
  17.  
  18. //
  19. // create elastic search secret
  20. //
  21. kubectl create secret generic elasticsearch-es-elastic-user --from-literal=elastic=elastic --namespace datachannels --dry-run=client --output=yaml 2>/dev/null | kubectl apply --filename -
  22.  
  23. //
  24. // create scoring admin secret
  25. //
  26. kubectl create secret generic scoring-admin --from-literal=admin=admin --namespace datachannels
  27.  
  28. //
  29. // Update Data-Channels environment (change approvedArtifacts value)
  30. //
  31. $ kubectl apply -f - <<!
  32. kind: Namespace
  33. apiVersion: v1
  34. metadata:
  35. name: datachannels
  36. labels:
  37. environment: "Data-Channels"
  38. annotations:
  39. publishedArtifactsOnly: "false"
  40. description: "Data channel environment"
  41. predecessors: '["Development"]'
  42. tag: orange
  43. !
  44.  
  45. //
  46. // Display Data-Channels environment
  47. //
  48. kubectl describe namespace datachannels
  49. Name: datachannels
  50. Labels: environment=Data-Channels
  51. Annotations: publishedArtifactsOnly: false
  52. description: Data channel environment
  53. predecessors: ["Development"]
  54. tag: orange
  55. Status: Active
  56. No resource quota.
  57. No LimitRange resource.
  58. //
  59. // Remove Data-Channels environment
  60. //
  61. kubectl delete namespaces datachannels