Skip to content
Snippets Groups Projects
Commit 7f770a28 authored by Jessica Yuen's avatar Jessica Yuen
Browse files

Rename binary to ks

parent c873c1f0
No related branches found
No related tags found
No related merge requests found
......@@ -104,11 +104,11 @@ install:
script:
- make VERSION="$VERSION" EXTRA_GO_FLAGS="$EXTRA_GO_FLAGS_TEST" test
- make vet
- rm -f ./kubecfg && make VERSION="$VERSION"
- rm -f ./ks && make VERSION="$VERSION"
- >
ldd ./kubecfg || otool -L ./kubecfg || :
- ./kubecfg help
- ./kubecfg version
ldd ./ks || otool -L ./ks || :
- ./ks help
- ./ks version
- |
if [ "$DO_INTEGRATION_TEST" = 1 ]; then
minikube update-context
......@@ -120,8 +120,8 @@ after_script: set +e
before_deploy:
- echo TARGET=$TARGET OS_NAME=$TRAVIS_OS_NAME GO_VERSION=$TRAVIS_GO_VERSION
- EXE_NAME=kubecfg-$(go env GOOS)-$(go env GOARCH)
- cp kubecfg $EXE_NAME
- EXE_NAME=ks-$(go env GOOS)-$(go env GOARCH)
- cp ks $EXE_NAME
- strip $EXE_NAME && ./$EXE_NAME version
- >
size $EXE_NAME || :
......
......@@ -31,21 +31,21 @@ GO_PACKAGES = ./cmd/... ./utils/... ./pkg/... ./metadata/... ./prototype/...
# Default cluster from this config is used for integration tests
KUBECONFIG = $(HOME)/.kube/config
all: kubecfg
all: ks
kubecfg:
$(GO) build $(GO_FLAGS) .
ks:
$(GO) build -o ks $(GO_FLAGS) .
test: gotest jsonnettest
gotest:
$(GO) test $(GO_FLAGS) $(GO_PACKAGES)
jsonnettest: kubecfg $(JSONNET_FILES)
# TODO: use `kubecfg check` once implemented
./kubecfg -J lib show -f $(KCFG_TEST_FILE) -f $(GUESTBOOK_FILE) >/dev/null
jsonnettest: ks $(JSONNET_FILES)
# TODO: use `ks check` once implemented
./ks -J lib show -f $(KCFG_TEST_FILE) -f $(GUESTBOOK_FILE) >/dev/null
integrationtest: kubecfg
integrationtest: ks
$(GINKGO) -tags 'integration' integration -- -kubeconfig $(KUBECONFIG) -kubecfg-bin $(abspath $<)
vet:
......@@ -55,7 +55,7 @@ fmt:
$(GOFMT) -s -w $(shell $(GO) list -f '{{.Dir}}' $(GO_PACKAGES))
clean:
$(RM) ./kubecfg
$(RM) ./ks
.PHONY: all test clean vet fmt
.PHONY: kubecfg
.PHONY: ks
# kubecfg
# ksonnet
[![Build Status](https://travis-ci.org/ksonnet/kubecfg.svg?branch=master)](https://travis-ci.org/ksonnet/kubecfg)
[![Go Report Card](https://goreportcard.com/badge/github.com/ksonnet/kubecfg)](https://goreportcard.com/report/github.com/ksonnet/kubecfg)
[![Build Status](https://travis-ci.org/ksonnet/ksonnet.svg?branch=master)](https://travis-ci.org/ksonnet/ksonnet)
[![Go Report Card](https://goreportcard.com/badge/github.com/ksonnet/ksonnet)](https://goreportcard.com/report/github.com/ksonnet/ksonnet)
A tool for managing Kubernetes resources as code.
`kubecfg` allows you to express the patterns across your
`ksonnet` allows you to express the patterns across your
infrastructure and reuse these powerful "templates" across many
services, and then manage those templates as files in version control.
The more complex your infrastructure is, the more you will gain from
......@@ -14,20 +14,17 @@ using kubecfg.
Status: Basic functionality works, and the tool is usable. The focus
now is on clearer error reporting and advanced features.
Yes, Google employees will recognise this as being very similar to a
similarly-named internal tool ;)
## Install
Pre-compiled executables exist for some platforms on
the [Github releases](https://github.com/ksonnet/kubecfg/releases)
the [Github releases](https://github.com/ksonnet/ksonnet/releases)
page.
To build from source:
```console
% PATH=$PATH:$GOPATH/bin
% go get github.com/ksonnet/kubecfg
% go get github.com/ksonnet/ksonnet
```
Requires golang >=1.7 and a functional cgo environment (C++ with libstdc++).
......@@ -38,26 +35,26 @@ avoid an immediate `Killed: 9`.
## Quickstart
```console
# Include <kubecfg.git>/lib in kubecfg/jsonnet library search path.
# Include <ksonnet.git>/lib in ksonnet/jsonnet library search path.
# Can also use explicit `-J` args everywhere.
% export KUBECFG_JPATH=/path/to/kubecfg/lib
% export KUBECFG_JPATH=/path/to/ksonnet/lib
# Show generated YAML
% kubecfg show -o yaml -f examples/guestbook.jsonnet
% ks show -o yaml -f examples/guestbook.jsonnet
# Create resources
% kubecfg apply -f examples/guestbook.jsonnet
% ks apply -f examples/guestbook.jsonnet
# Modify configuration (downgrade gb-frontend image)
% sed -i.bak '\,gcr.io/google-samples/gb-frontend,s/:v4/:v3/' examples/guestbook.jsonnet
# See differences vs server
% kubecfg diff -f examples/guestbook.jsonnet
% ks diff -f examples/guestbook.jsonnet
# Update to new config
% kubecfg apply -f examples/guestbook.jsonnet
% ks apply -f examples/guestbook.jsonnet
# Clean up after demo
% kubecfg delete -f examples/guestbook.jsonnet
% ks delete -f examples/guestbook.jsonnet
```
## Features
......@@ -80,7 +77,7 @@ or to recover from disaster.
### Jsonnet
Kubecfg relies heavily on [jsonnet](http://jsonnet.org/) to describe
ksonnet relies heavily on [jsonnet](http://jsonnet.org/) to describe
Kubernetes resources, and is really just a thin Kubernetes-specific
wrapper around jsonnet evaluation. You should read the jsonnet
[tutorial](http://jsonnet.org/docs/tutorial.html), and skim the functions available in the jsonnet [`std`](http://jsonnet.org/docs/stdlib.html)
......
......@@ -129,20 +129,20 @@ files.`,
Example: ` # Create or update all resources described in a ksonnet application, and
# running in the 'dev' environment. Can be used in any subdirectory of the
# application.
ksonnet apply dev
ks apply dev
# Create or update resources described in a YAML file. Automatically picks up
# the cluster's location from '$KUBECONFIG'.
ksonnet appy -f ./pod.yaml
ks appy -f ./pod.yaml
# Create or update resources described in the JSON file. Changes are deployed
# to the cluster pointed at the 'dev' environment.
ksonnet apply dev -f ./pod.json
ks apply dev -f ./pod.json
# Update resources described in a YAML file, and running in cluster referred
# to by './kubeconfig'.
ksonnet apply --kubeconfig=./kubeconfig -f ./pod.yaml
ks apply --kubeconfig=./kubeconfig -f ./pod.yaml
# Display set of actions we will execute when we run 'apply'.
ksonnet apply dev --dry-run`,
ks apply dev --dry-run`,
}
......@@ -90,17 +90,17 @@ ksonnet applications are accepted, as well as normal JSON, YAML, and Jsonnet
files.`,
Example: ` # Delete all resources described in a ksonnet application, from the 'dev'
# environment. Can be used in any subdirectory of the application.
ksonnet delete dev
ks delete dev
# Delete resources described in a YAML file. Automatically picks up the
# cluster's location from '$KUBECONFIG'.
ksonnet delete -f ./pod.yaml
ks delete -f ./pod.yaml
# Delete resources described in the JSON file from the 'dev' environment. Can
# be used in any subdirectory of the application.
ksonnet delete dev -f ./pod.json
ks delete dev -f ./pod.json
# Delete resources described in a YAML file, and running in the cluster
# specified by the current context in specified kubeconfig file.
ksonnet delete --kubeconfig=./kubeconfig -f ./pod.yaml`,
ks delete --kubeconfig=./kubeconfig -f ./pod.yaml`,
}
......@@ -88,17 +88,17 @@ files.`,
Example: ` # Show diff between resources described in a local ksonnet application and
# the cluster referenced by the 'dev' environment. Can be used in any
# subdirectory of the application.
ksonnet diff dev
ks diff dev
# Show diff between resources described in a YAML file and the cluster
# referenced in '$KUBECONFIG'.
ksonnet diff -f ./pod.yaml
ks diff -f ./pod.yaml
# Show diff between resources described in a JSON file and the cluster
# referenced by the environment 'dev'.
ksonnet diff dev -f ./pod.json
ks diff dev -f ./pod.json
# Show diff between resources described in a YAML file and the cluster
# referred to by './kubeconfig'.
ksonnet diff --kubeconfig=./kubeconfig -f ./pod.yaml`,
ks diff --kubeconfig=./kubeconfig -f ./pod.yaml`,
}
......@@ -58,7 +58,7 @@ var envCmd = &cobra.Command{
Use: "env",
Short: `Manage ksonnet environments`,
Long: `An environment acts as a sort of "named cluster", allowing for commands like
'ksonnet apply dev', which applies the ksonnet application to the "dev cluster".
'ks apply dev', which applies the ksonnet application to the "dev cluster".
Additionally, environments allow users to cache data about the cluster it points
to, including data needed to run 'verify', and a version of ksonnet-lib that is
generated based on the flags the API server was started with (e.g., RBAC enabled
......@@ -135,7 +135,7 @@ var envAddCmd = &cobra.Command{
include punctuation, so names like '../foo' are not allowed.
An environment acts as a sort of "named cluster", allowing for commands like
'ksonnet apply dev', which applies the ksonnet application to the "dev cluster".
'ks apply dev', which applies the ksonnet application to the "dev cluster".
For more information on what an environment is and how they work, run 'help
env'.
......@@ -157,17 +157,17 @@ environments/
swagger.json
spec.json [This will contain the uri of the environment]`,
Example: ` # Initialize a new staging environment at 'us-west'. Using the
# namespace 'my-namespace'. The directory structure rooted at 'us-west' in the
# documentation above will be generated.
ksonnet env add us-west/staging https://kubecfg-1.us-west.elb.amazonaws.com --namespace my-namespace
# namespace 'my-namespace'. The directory structure rooted at 'us-west' in the
# documentation above will be generated.
ks env add us-west/staging https://ksonnet-1.us-west.elb.amazonaws.com
# Initialize a new staging environment at us-west, using the OpenAPI specification
# generated in the Kubernetes v1.7.1 build to generate 'ksonnet-lib'.
ksonnet env add us-west/staging https://kubecfg-1.us-west.elb.amazonaws.com --api-spec=version:v1.7.1
ks env add us-west/staging https://ksonnet-1.us-west.elb.amazonaws.com --api-spec=version:v1.7.1
# Initialize a new development environment locally. This will overwrite the
# default 'default' directory structure generated by 'ksonnet-init'.
ksonnet env add default localhost:8000`,
ks env add default localhost:8000`,
}
var envRmCmd = &cobra.Command{
......@@ -207,7 +207,7 @@ parent directories are subsequently deleted.`,
Example: ` # Remove the directory 'us-west/staging' and all contents
# in the 'environments' directory. This will also remove the parent directory
# 'us-west' if it is empty.
ksonnet env rm us-west/staging`,
ks env rm us-west/staging`,
}
var envListCmd = &cobra.Command{
......@@ -287,12 +287,12 @@ var envSetCmd = &cobra.Command{
the name of an environment will also update the directory structure in
'environments'.`,
Example: ` # Updates the URI of the environment 'us-west/staging'.
ksonnet env set us-west/staging --uri=http://example.com
ks env set us-west/staging --uri=http://example.com
# Updates the namespace of the environment 'us-west/staging'.
ksonnet env set us-west/staging --namespace=staging
ks env set us-west/staging --namespace=staging
# Updates both the name and the URI of the environment 'us-west/staging'.
# Updating the name will update the directory structure in 'environments'
ksonnet env set us-west/staging --uri=http://example.com --name=us-east/staging`,
ks env set us-west/staging --uri=http://example.com --name=us-east/staging`,
}
......@@ -115,13 +115,13 @@ consists of two steps:
Example: ` # Initialize ksonnet application, using the capabilities of live cluster
# specified in the $KUBECONFIG environment variable (specifically: the
# current context) to generate 'ksonnet-lib'.
ksonnet init app-name
ks init app-name
# Initialize ksonnet application, using the OpenAPI specification generated
# in the Kubenetes v1.7.1 build to generate 'ksonnet-lib'.
ksonnet init app-name --api-spec=version:v1.7.1
ks init app-name --api-spec=version:v1.7.1
# Initialize ksonnet application, using an OpenAPI specification file
# generated by a build of Kubernetes to generate 'ksonnet-lib'.
ksonnet init app-name --api-spec=file:swagger.json`,
ks init app-name --api-spec=file:swagger.json`,
}
......@@ -66,21 +66,21 @@ Commands:
# identifier to disambiguate it among other known prototypes, which is why
# 'simple-deployment' is given as argument instead of the fully-qualified
# name.
ksonnet prototype describe simple-deployment
ks prototype describe simple-deployment
# Instantiate prototype 'io.ksonnet.pkg.prototype.simple-deployment', using
# the 'nginx' image, and port 80 exposed.
#
# SEE ALSO: Note above for a description of why this subcommand can take
# 'simple-deployment' instead of the fully-qualified prototype name.
ksonnet prototype use simple-deployment \
ks prototype use simple-deployment \
--name=nginx \
--image=nginx \
--port=80 \
--portName=http
# Search known prototype metadata for the string 'deployment'.
ksonnet prototype search deployment`,
ks prototype search deployment`,
}
var prototypeListCmd = &cobra.Command{
......@@ -151,7 +151,7 @@ ambiguously, in which case 'use' will fail, while 'simple-deployment' might be
unique enough to resolve to 'io.ksonnet.pkg.prototype.simple-deployment'.`,
Example: ` # Display documentation about prototype, including:
ksonnet prototype describe io.ksonnet.pkg.prototype.simple-deployment
ks prototype describe io.ksonnet.pkg.prototype.simple-deployment
# Display documentation about prototype using a unique suffix of an
# identifier. That is, this command only requires a long enough suffix to
......@@ -159,7 +159,7 @@ unique enough to resolve to 'io.ksonnet.pkg.prototype.simple-deployment'.`,
# 'simple-deployment' is enough to uniquely identify
# 'io.ksonnet.pkg.prototype.simple-deployment', but 'deployment' might not
# be, as several names end with that suffix.
ksonnet prototype describe simple-deployment`,
ks prototype describe simple-deployment`,
}
var prototypeSearchCmd = &cobra.Command{
......@@ -186,7 +186,7 @@ var prototypeSearchCmd = &cobra.Command{
},
Long: `Search ksonnet for prototypes whose names contain 'name-substring'.`,
Example: ` # Search known prototype metadata for the string 'deployment'.
ksonnet prototype search deployment`,
ks prototype search deployment`,
}
var prototypePreviewCmd = &cobra.Command{
......@@ -248,20 +248,20 @@ unique enough to resolve to 'io.ksonnet.pkg.single-port-deployment'.`,
Example: ` # Preview prototype 'io.ksonnet.pkg.single-port-deployment', using the
# 'nginx' image, and port 80 exposed.
ksonnet prototype preview io.ksonnet.pkg.prototype.simple-deployment \
ks prototype preview io.ksonnet.pkg.prototype.simple-deployment \
--name=nginx \
--image=nginx
# Preview prototype using a unique suffix of an identifier. See
# introduction of help message for more information on how this works.
ksonnet prototype preview simple-deployment \
ks prototype preview simple-deployment \
--name=nginx \
--image=nginx
# Preview prototype 'io.ksonnet.pkg.single-port-deployment' as YAML,
# placing the result in 'components/nginx-depl.yaml. Note that some templates
# do not have a YAML or JSON versions.
ksonnet prototype preview deployment nginx-depl yaml \
ks prototype preview deployment nginx-depl yaml \
--name=nginx \
--image=nginx`,
}
......@@ -334,7 +334,7 @@ following command will expand template 'io.ksonnet.pkg.single-port-deployment'
and place it in the file 'components/nginx-depl.jsonnet' (since by default
ksonnet will expand templates as Jsonnet).
ksonnet prototype use io.ksonnet.pkg.single-port-deployment nginx-depl \
ks prototype use io.ksonnet.pkg.single-port-deployment nginx-depl \
--name=nginx \
--image=nginx
......@@ -350,7 +350,7 @@ unique enough to resolve to 'io.ksonnet.pkg.single-port-deployment'.`,
Example: ` # Instantiate prototype 'io.ksonnet.pkg.single-port-deployment', using the
# 'nginx' image. The expanded prototype is placed in
# 'components/nginx-depl.jsonnet'.
ksonnet prototype use io.ksonnet.pkg.prototype.simple-deployment nginx-depl \
ks prototype use io.ksonnet.pkg.prototype.simple-deployment nginx-depl \
--name=nginx \
--image=nginx
......@@ -359,14 +359,14 @@ unique enough to resolve to 'io.ksonnet.pkg.single-port-deployment'.`,
# 'components/nginx-depl.jsonnet'. See introduction of help message for more
# information on how this works. Note that if you have imported another
# prototype with this suffix, this may resolve ambiguously for you.
ksonnet prototype use deployment nginx-depl \
ks prototype use deployment nginx-depl \
--name=nginx \
--image=nginx
# Instantiate prototype 'io.ksonnet.pkg.single-port-deployment' as YAML,
# placing the result in 'components/nginx-depl.yaml. Note that some templates
# do not have a YAML or JSON versions.
ksonnet prototype use deployment nginx-depl yaml \
ks prototype use deployment nginx-depl yaml \
--name=nginx \
--image=nginx`,
}
......
......@@ -95,7 +95,7 @@ func bindClientGoFlags(cmd *cobra.Command) {
// RootCmd is the root of cobra subcommand tree
var RootCmd = &cobra.Command{
Use: "kubecfg",
Use: "ks",
Short: "Synchronise Kubernetes resources with config files",
SilenceErrors: true,
SilenceUsage: true,
......
......@@ -112,16 +112,16 @@ files.`,
Example: ` # Create or update all resources described in a ksonnet application, and
# running in the 'dev' environment. Can be used in any subdirectory of the
# application.
ksonnet update dev
ks update dev
# Create or update resources described in a YAML file. Automatically picks up
# the cluster's location from '$KUBECONFIG'.
ksonnet appy -f ./pod.yaml
ks update -f ./pod.yaml
# Update resources described in a YAML file, and running in cluster referred
# to by './kubeconfig'.
ksonnet update --kubeconfig=./kubeconfig -f ./pod.yaml
ks update --kubeconfig=./kubeconfig -f ./pod.yaml
# Display set of actions we will execute when we run 'update'.
ksonnet update dev --dry-run`,
ks update dev --dry-run`,
}
......@@ -23,9 +23,9 @@
// Expects to be run with ../lib in the jsonnet search path:
// ```
// export KUBECFG_JPATH=$PWD/../lib
// kubecfg apply guestbook.jsonnet
// ks apply guestbook.jsonnet
// # poke at $(minikube service --url frontend), etc
// kubecfg delete guestbook.jsonnet
// ks delete guestbook.jsonnet
// ```
local example = import "example.libsonnet";
......
......@@ -31,7 +31,7 @@ import (
)
var kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
var kubecfgBin = flag.String("kubecfg-bin", "kubecfg", "path to kubecfg executable under test")
var kubecfgBin = flag.String("kubecfg-bin", "ks", "path to kubecfg executable under test")
func init() {
if missingVersions := api.Registry.ValidateEnvRequestedVersions(); len(missingVersions) != 0 {
......
......@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Run me with `../kubecfg show -f kubecfg_test.jsonnet`
// Run me with `../ks show -f kubecfg_test.jsonnet`
local kubecfg = import "kubecfg.libsonnet";
assert kubecfg.parseJson("[3, 4]") == [3, 4];
......
......@@ -58,7 +58,7 @@ to 'targetLabelSelector', at 'targetPort'. Since 'targetLabelSelector' is an
object literal that specifies which labels the service is meant to target, this
will typically look something like:
ksonnet prototype use service --targetLabelSelector "{app: 'nginx'}" [...]`,
ks prototype use service --targetLabelSelector "{app: 'nginx'}" [...]`,
ShortDescription: `Service that exposes a single port`,
YAMLBody: []string{
`kind: Service`,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment