Skip to content

Latest commit

 

History

History
117 lines (88 loc) · 5.41 KB

ks_init.md

File metadata and controls

117 lines (88 loc) · 5.41 KB

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.

app-name/
  .ksonnet/      Metadata for ksonnet
  app.yaml       Application specifications (e.g. name, API version)
  components/    Top-level Kubernetes objects defining the application
  environments/  Kubernetes cluster definitions
    default/     Default environment, initialized from the current kubeconfig
      .metadata/ Contains a versioned ksonnet-lib, see [1] for details
  lib/           User-written .libsonnet files
  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.

Related Commands

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

Syntax

ks init <app-name> [flags]

Examples

# Initialize a ksonnet application, based on cluster information from the
# active kubeconfig file (as specified by the environment variable $KUBECONFIG).
# More specifically, the current context is used.
ks init app-name

# Initialize a ksonnet application, using the context 'dev' from the current
# kubeconfig file ($KUBECONFIG). The default environment is created using the
# server address and default namespace located at the context 'dev'.
ks init app-name --context=dev

# Initialize a ksonnet application, using the context 'dev' and the namespace
# 'dc-west' from the current kubeconfig file ($KUBECONFIG). The default environment
# is created using the server address from the 'dev' context, and the specified
# 'dc-west' namespace.
ks init app-name --context=dev --namespace=dc-west

# Initialize a ksonnet application, using v1.7.1 of the Kubernetes OpenAPI spec
# to generate 'ksonnet-lib'.
ks init app-name --api-spec=version:v1.7.1

# Initialize a ksonnet application, using the OpenAPI spec generated by a
# specific build of Kubernetes to generate 'ksonnet-lib'.
ks init app-name --api-spec=file:swagger.json

# Initialize a ksonnet application, outputting the application directory into
# the specified 'custom-location'.
ks init app-name --dir=custom-location

Options

      --api-spec string                Manually specified Kubernetes API version. The corresponding OpenAPI spec is used to generate ksonnet's Kubernetes libraries
      --as string                      Username to impersonate for the operation
      --as-group stringArray           Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
      --certificate-authority string   Path to a cert file for the certificate authority
      --client-certificate string      Path to a client certificate file for TLS
      --client-key string              Path to a client key file for TLS
      --cluster string                 The name of the kubeconfig cluster to use
      --context string                 The name of the kubeconfig context to use
      --env string                     Name of initial environment to create
  -h, --help                           help for init
      --insecure-skip-tls-verify       If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
      --kubeconfig string              Path to a kubeconfig file. Alternative to env var $KUBECONFIG.
  -n, --namespace string               If present, the namespace scope for this CLI request
      --password string                Password for basic authentication to the API server
      --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")
      --server string                  The address and port of the Kubernetes API server
      --skip-default-registries        Skip configuration of default registries
      --token string                   Bearer token for authentication to the API server
      --user string                    The name of the kubeconfig user to use
      --username string                Username for basic authentication to the API server

Options inherited from parent commands

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

SEE ALSO

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