ks init

Initialize a ksonnet application

Synopsis

The init command initializes a ksonnet application in a new directory, app-name.

This command generates all the project scaffolding required to begin creating and
deploying components to Kubernetes clusters.

ksonnet applications are initialized based on your current cluster configurations,
as defined in your $KUBECONFIG environment variable. The Examples section
below demonstrates how to customize these configurations.

Creating a ksonnet application results in the following directory tree.

  1. app-name/
  2. .ksonnet/ Metadata for ksonnet
  3. app.yaml Application specifications (e.g. name, API version)
  4. components/ Top-level Kubernetes objects defining the application
  5. environments/ Kubernetes cluster definitions
  6. default/ Default environment, initialized from the current kubeconfig
  7. .metadata/ Contains a versioned ksonnet-lib, see [1] for details
  8. lib/ User-written .libsonnet files
  9. vendor/ Libraries that define prototypes and their constituent parts

To begin populating your ksonnet application, see the docs for ks generate .

[1] ksonnet-lib is a Jsonnet helper library that wraps Kubernetes-API-compatible
types. A specific version of ksonnet-lib is automatically provided for each
environment. Users can set flags to generate the library based on a variety of data,
including server configuration and an OpenAPI specification of a specific Kubernetes
build. By default, this is generated using cluster information specified by the
current context, in the file pointed to by $KUBECONFIG.

  • ks generate — Use the specified prototype to generate a component manifest

Syntax

  1. ks init <app-name> [flags]

Examples

  1. # Initialize a ksonnet application, based on cluster information from the
  2. # active kubeconfig file (as specified by the environment variable $KUBECONFIG).
  3. # More specifically, the current context is used.
  4. ks init app-name
  5. # Initialize a ksonnet application, using the context 'dev' from the current
  6. # kubeconfig file ($KUBECONFIG). The default environment is created using the
  7. # server address and default namespace located at the context 'dev'.
  8. ks init app-name --context=dev
  9. # Initialize a ksonnet application, using the context 'dev' and the namespace
  10. # 'dc-west' from the current kubeconfig file ($KUBECONFIG). The default environment
  11. # is created using the server address from the 'dev' context, and the specified
  12. # 'dc-west' namespace.
  13. ks init app-name --context=dev --namespace=dc-west
  14. # Initialize a ksonnet application, using v1.7.1 of the Kubernetes OpenAPI spec
  15. # to generate 'ksonnet-lib'.
  16. ks init app-name --api-spec=version:v1.7.1
  17. # Initialize a ksonnet application, using the OpenAPI spec generated by a
  18. # specific build of Kubernetes to generate 'ksonnet-lib'.
  19. ks init app-name --api-spec=file:swagger.json
  20. # Initialize a ksonnet application, outputting the application directory into
  21. # the specified 'custom-location'.
  22. ks init app-name --dir=custom-location

Options

  1. --api-spec string Manually specified Kubernetes API version. The corresponding OpenAPI spec is used to generate ksonnet's Kubernetes libraries
  2. --as string Username to impersonate for the operation
  3. --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
  4. --certificate-authority string Path to a cert file for the certificate authority
  5. --client-certificate string Path to a client certificate file for TLS
  6. --client-key string Path to a client key file for TLS
  7. --cluster string The name of the kubeconfig cluster to use
  8. --context string The name of the kubeconfig context to use
  9. --env string Name of initial environment to create
  10. -h, --help help for init
  11. --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
  12. --kubeconfig string Path to a kubeconfig file. Alternative to env var $KUBECONFIG.
  13. -n, --namespace string If present, the namespace scope for this CLI request
  14. --password string Password for basic authentication to the API server
  15. --request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
  16. --server string The address and port of the Kubernetes API server
  17. --skip-default-registries Skip configuration of default registries
  18. --token string Bearer token for authentication to the API server
  19. --user string The name of the kubeconfig user to use
  20. --username string Username for basic authentication to the API server

Options inherited from parent commands

  1. --dir string Ksonnet application root to use; Defaults to CWD
  2. --tls-skip-verify Skip verification of TLS server certificates
  3. -v, --verbose count Increase verbosity. May be given multiple times.

SEE ALSO

  • ks - Configure your application to deploy to a Kubernetes cluster