forked from kubernetes-sigs/kustomize
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d5b5adf
Showing
22 changed files
with
1,799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
SHELL := /bin/bash -euo pipefail | ||
|
||
config_file_name = Kube-manifest.yaml | ||
example_config = docs/$(config_file_name) | ||
|
||
.PHONY: all | ||
all: docs | ||
|
||
# In a branch, run 'make docs' to update docs with | ||
# generated code, then merge it to master. | ||
docs: $(example_config) | ||
|
||
# Use kustomize to create the standard kustomize configuration | ||
# file that appears in the website's documentation. | ||
$(example_config): /tmp/bin/kustomize | ||
rm -f TMP | ||
echo "# This is a generated example; do not edit. Rebuild with 'make docs'." >> TMP | ||
echo " " >> TMP | ||
/tmp/bin/kustomize init | ||
cat $(config_file_name) >> TMP | ||
mv TMP $(example_config) | ||
rm $(config_file_name) | ||
|
||
/tmp/bin/kustomize: | ||
go build -o /tmp/bin/kustomize kustomize.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# kustomize | ||
|
||
[applied]: docs/glossary.md#apply | ||
[base]: docs/glossary.md#base | ||
[declarative configuration]: docs/glossary.md#declarative-application-management | ||
[demo]: demos/README.md | ||
[imageBase]: docs/base.jpg | ||
[imageOverlay]: docs/overlay.jpg | ||
[manifest]: docs/glossary.md#manifest | ||
[overlay]: docs/glossary.md#overlay | ||
[resources]: docs/glossary.md#resource | ||
[workflows]: docs/workflows.md | ||
|
||
`kustomize` is a command line tool supporting | ||
template-free customization of declarative | ||
configuration targetted to kubernetes. | ||
|
||
## Installation | ||
|
||
Assumes [Go](https://golang.org/) is installed | ||
and your `PATH` contains `$GOPATH/bin`: | ||
|
||
<!-- @installkustomize @test --> | ||
``` | ||
go get k8s.io/kubectl/cmd/kustomize | ||
``` | ||
|
||
## Usage | ||
|
||
#### 1) Make a base | ||
|
||
A [base] configuration is a [manifest] listing a set of | ||
k8s [resources] - deployments, services, configmaps, | ||
secrets that serve some common purpose. | ||
|
||
![base image][imageBase] | ||
|
||
#### 2) Customize it with overlays | ||
|
||
An [overlay] customizes your base along different dimensions | ||
for different purposes or different teams, e.g. for | ||
_development, staging and production_. | ||
|
||
![overlay image][imageOverlay] | ||
|
||
#### 3) Run kustomize | ||
|
||
Run kustomize on your overlay. The result | ||
is printed to `stdout` as a set of complete | ||
resources, ready to be [applied] to a cluster. | ||
|
||
For more details, try a [demo]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Steps to run build locally | ||
|
||
Install container-builder-local from github and define GOOS, GOARCH, OUTPUT env | ||
variables and run following command | ||
|
||
```sh | ||
container-builder-local --config=cmd/kustomize/build/cloudbuild_local.yaml --dryrun=false --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT . | ||
``` | ||
|
||
## Steps to submit build to Google container builder | ||
|
||
You need to be at the repo level to be able to run the following command | ||
|
||
``` | ||
gcloud container builds submit . --config=cmd/kustomize/build/cloudbuild.yaml --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
set -x | ||
|
||
# Google Container Builder automatically checks out all the code under the /workspace directory, | ||
# but we actually want it to under the correct expected package in the GOPATH (/go) | ||
# - Create the directory to host the code that matches the expected GOPATH package locations | ||
# - Use /go as the default GOPATH because this is what the image uses | ||
# - Link our current directory (containing the source code) to the package location in the GOPATH | ||
export PKG=k8s.io | ||
export REPO=kubectl | ||
export CMD=kustomize | ||
|
||
mkdir -p /go/src/$PKG | ||
ln -s $(pwd) /go/src/$PKG/$REPO | ||
|
||
# Create the output directory for the binaries we will build | ||
# Make sure CGO is 0 so the binaries are statically compiled and linux which is necessary for cross compiling go | ||
export CGO=0 | ||
export DEST=/workspace/_output/$CMD/bin | ||
mkdir -p $DEST || echo "" | ||
|
||
go build -o $DEST/$CMD $PKG/$REPO/cmd/$CMD | ||
|
||
# Explicitly set the values of the variables in package "X" using ldflag so that they are statically compiled into | ||
# the "version" command | ||
export GITCOMMIT=$(git rev-parse HEAD) | ||
export BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
export X=$PKG/$REPO/cmd/$CMD/version | ||
go build -o $DEST/$CMD \ | ||
-ldflags "-X $X.kustomizeVersion=$TAG -X $X.goos=$GOOS -X $X.goarch=$GOARCH -X $X.gitCommit=$GITCOMMIT -X $X.buildDate=$BUILDDATE" \ | ||
$PKG/$REPO/cmd/$CMD | ||
|
||
# Generate the tar archive | ||
cd /workspace/_output/ | ||
tar -czvf /workspace/$CMD-$VERSION-$GOOS-$GOARCH.tar.gz $CMD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# TODO(droot): add instructions for running in production. | ||
steps: | ||
- name: "ubuntu" | ||
args: ["mkdir", "-p", "/workspace/_output"] | ||
- name: "golang:1.10-stretch" | ||
args: ["bash", "cmd/kustomize/build/build.sh"] | ||
env: | ||
- 'GOOS=${_GOOS}' | ||
- 'GOARCH=${_GOARCH}' | ||
- 'VERSION=${TAG_NAME}' | ||
- name: 'gcr.io/cloud-builders/gsutil' | ||
args: ['-h', 'Content-Type:application/gzip', 'cp', '-a', 'public-read', 'kustomize-${TAG_NAME}-${_GOOS}-${_GOARCH}.tar.gz', 'gs://kustomize-release/kustomize-${TAG_NAME}-${_GOOS}-${_GOARCH}.tar.gz'] | ||
env: | ||
- 'GOOS=${_GOOS}' | ||
- 'GOARCH=${_GOARCH}' | ||
- 'VERSION=${TAG_NAME}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Instructions to run locally: | ||
# Download google container builder: https://github.com/kubernetes-sigs/container-builder-local | ||
# Set you GOOS and GOARCH vars to match your system | ||
# Set OUTPUT to the location to write the directory containing the tar.gz | ||
# $ container-builder-local --config=build/cloudbuild_local.yaml --dryrun=false \ | ||
# --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT . | ||
# Release tar will be in $OUTPUT | ||
|
||
steps: | ||
- name: "ubuntu" | ||
args: ["mkdir", "-p", "/workspace/_output"] | ||
- name: "golang:1.10-stretch" | ||
args: ["bash", "cmd/kustomize/build/build.sh"] | ||
env: | ||
- 'GOOS=${_GOOS}' | ||
- 'GOARCH=${_GOARCH}' | ||
- 'VERSION=${TAG_NAME}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Demos | ||
|
||
These demos are covered by presubmit tests. | ||
|
||
* [hello world](helloWorld.md) - Deploy multiple | ||
(differently configured) instances of a simple Hello | ||
World server. | ||
|
||
* [mysql](mySql.md) - Create a mySql production | ||
configuration from scratch. | ||
|
||
* [springboot](springboot.md) - Create a Spring Boot application production | ||
configuration from scratch. |
Oops, something went wrong.