Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 3.32 KB

File metadata and controls

70 lines (52 loc) · 3.32 KB

cs generate kubernetes

Generates kubernetes artifacts based on a ci.yml of a workspace

Synopsis

The generated artifacts will be saved in the output folder (default is ./export). In the deployment files the image name is set to '/-:latest'. The nginx router is set to '/-cs-router:latest' as image name. If the imagePrefix is not set, it uses '/:latest'. The imagePrefix is used as the namespace for the kubernetes resources, if the prefix is not set, it defaults to 'default'. It then generates following artifacts inside the output folder:

./ Each service deployment file is exported to a separate folder. .//.yml Kubernetes deployment and service resource to run a pod for the service. ./ingress.yml ingress resource to route traffic to the different services.

Codesphere recommends adding the generated artifacts to the source code repository.

Limitations:

  • Environment variables have to be set explicitly as the Codesphere environment has its own way to provide env variables.
  • The workspace ID, team ID etc. are not automatically available and have to be set explicitly.
  • Hardcoded workspace urls don't work outside of the Codesphere environment.
  • Each dockerfile of your services contain all prepare steps. To have the smallest image possible you would have to delete all unused steps in each service.
cs generate kubernetes [flags]

Examples

# Generate kubernetes for workspace 1234
$ cs generate kubernetes -w 1234

# Generate kubernetes for workspace 1234 based on ci profile ci.prod.yml
$ cs generate kubernetes -w 1234 -i ci.prod.yml

Options

  -h, --help                  help for kubernetes
      --hostname string       hostname for the ingress to match (default "localhost")
  -p, --imagePrefix string    Image prefix used for the exported images (should be the same as used in generate images)
      --ingressClass string   ingress class for the ingress resource (default "nginx")
  -n, --namespace string      namespace of generated kubernetes artifacts (default "default")
      --pullsecret string     pullsecret for the pod's images (e.g. for a private registry)
  -r, --registry string       Registry where images are pushed to (should be the same as used in generate images)

Options inherited from parent commands

  -a, --api string        URL of Codesphere API (can also be CS_API)
      --branch string     Branch of the repository to clone if the input file is not found (default "main")
  -f, --force             Overwrite any files if existing
  -i, --input string      CI profile to use as input for generation, relative to repository root (default "ci.yml")
  -o, --output string     Output path of the folder including generated artifacts, relative to repository root (default "export")
      --reporoot string   root directory of the workspace repository to export. Will be used to clone the repository if it doesn't exist. (default "./workspace-repo")
  -t, --team int          Team ID (relevant for some commands, can also be CS_TEAM_ID) (default -1)
  -v, --verbose           Verbose output
  -w, --workspace int     Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID) (default -1)

SEE ALSO