Skip to content

Commit d5b5adf

Browse files
Liujingfang1droot
authored andcommitted
change kinflate to kustomize
0 parents  commit d5b5adf

22 files changed

+1799
-0
lines changed

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
SHELL := /bin/bash -euo pipefail
2+
3+
config_file_name = Kube-manifest.yaml
4+
example_config = docs/$(config_file_name)
5+
6+
.PHONY: all
7+
all: docs
8+
9+
# In a branch, run 'make docs' to update docs with
10+
# generated code, then merge it to master.
11+
docs: $(example_config)
12+
13+
# Use kustomize to create the standard kustomize configuration
14+
# file that appears in the website's documentation.
15+
$(example_config): /tmp/bin/kustomize
16+
rm -f TMP
17+
echo "# This is a generated example; do not edit. Rebuild with 'make docs'." >> TMP
18+
echo " " >> TMP
19+
/tmp/bin/kustomize init
20+
cat $(config_file_name) >> TMP
21+
mv TMP $(example_config)
22+
rm $(config_file_name)
23+
24+
/tmp/bin/kustomize:
25+
go build -o /tmp/bin/kustomize kustomize.go

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# kustomize
2+
3+
[applied]: docs/glossary.md#apply
4+
[base]: docs/glossary.md#base
5+
[declarative configuration]: docs/glossary.md#declarative-application-management
6+
[demo]: demos/README.md
7+
[imageBase]: docs/base.jpg
8+
[imageOverlay]: docs/overlay.jpg
9+
[manifest]: docs/glossary.md#manifest
10+
[overlay]: docs/glossary.md#overlay
11+
[resources]: docs/glossary.md#resource
12+
[workflows]: docs/workflows.md
13+
14+
`kustomize` is a command line tool supporting
15+
template-free customization of declarative
16+
configuration targetted to kubernetes.
17+
18+
## Installation
19+
20+
Assumes [Go](https://golang.org/) is installed
21+
and your `PATH` contains `$GOPATH/bin`:
22+
23+
<!-- @installkustomize @test -->
24+
```
25+
go get k8s.io/kubectl/cmd/kustomize
26+
```
27+
28+
## Usage
29+
30+
#### 1) Make a base
31+
32+
A [base] configuration is a [manifest] listing a set of
33+
k8s [resources] - deployments, services, configmaps,
34+
secrets that serve some common purpose.
35+
36+
![base image][imageBase]
37+
38+
#### 2) Customize it with overlays
39+
40+
An [overlay] customizes your base along different dimensions
41+
for different purposes or different teams, e.g. for
42+
_development, staging and production_.
43+
44+
![overlay image][imageOverlay]
45+
46+
#### 3) Run kustomize
47+
48+
Run kustomize on your overlay. The result
49+
is printed to `stdout` as a set of complete
50+
resources, ready to be [applied] to a cluster.
51+
52+
For more details, try a [demo].

build/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Steps to run build locally
2+
3+
Install container-builder-local from github and define GOOS, GOARCH, OUTPUT env
4+
variables and run following command
5+
6+
```sh
7+
container-builder-local --config=cmd/kustomize/build/cloudbuild_local.yaml --dryrun=false --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT .
8+
```
9+
10+
## Steps to submit build to Google container builder
11+
12+
You need to be at the repo level to be able to run the following command
13+
14+
```
15+
gcloud container builds submit . --config=cmd/kustomize/build/cloudbuild.yaml --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH
16+
```

build/build.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -x
19+
20+
# Google Container Builder automatically checks out all the code under the /workspace directory,
21+
# but we actually want it to under the correct expected package in the GOPATH (/go)
22+
# - Create the directory to host the code that matches the expected GOPATH package locations
23+
# - Use /go as the default GOPATH because this is what the image uses
24+
# - Link our current directory (containing the source code) to the package location in the GOPATH
25+
export PKG=k8s.io
26+
export REPO=kubectl
27+
export CMD=kustomize
28+
29+
mkdir -p /go/src/$PKG
30+
ln -s $(pwd) /go/src/$PKG/$REPO
31+
32+
# Create the output directory for the binaries we will build
33+
# Make sure CGO is 0 so the binaries are statically compiled and linux which is necessary for cross compiling go
34+
export CGO=0
35+
export DEST=/workspace/_output/$CMD/bin
36+
mkdir -p $DEST || echo ""
37+
38+
go build -o $DEST/$CMD $PKG/$REPO/cmd/$CMD
39+
40+
# Explicitly set the values of the variables in package "X" using ldflag so that they are statically compiled into
41+
# the "version" command
42+
export GITCOMMIT=$(git rev-parse HEAD)
43+
export BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
44+
export X=$PKG/$REPO/cmd/$CMD/version
45+
go build -o $DEST/$CMD \
46+
-ldflags "-X $X.kustomizeVersion=$TAG -X $X.goos=$GOOS -X $X.goarch=$GOARCH -X $X.gitCommit=$GITCOMMIT -X $X.buildDate=$BUILDDATE" \
47+
$PKG/$REPO/cmd/$CMD
48+
49+
# Generate the tar archive
50+
cd /workspace/_output/
51+
tar -czvf /workspace/$CMD-$VERSION-$GOOS-$GOARCH.tar.gz $CMD

build/cloudbuild.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# TODO(droot): add instructions for running in production.
16+
steps:
17+
- name: "ubuntu"
18+
args: ["mkdir", "-p", "/workspace/_output"]
19+
- name: "golang:1.10-stretch"
20+
args: ["bash", "cmd/kustomize/build/build.sh"]
21+
env:
22+
- 'GOOS=${_GOOS}'
23+
- 'GOARCH=${_GOARCH}'
24+
- 'VERSION=${TAG_NAME}'
25+
- name: 'gcr.io/cloud-builders/gsutil'
26+
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']
27+
env:
28+
- 'GOOS=${_GOOS}'
29+
- 'GOARCH=${_GOARCH}'
30+
- 'VERSION=${TAG_NAME}'

build/cloudbuild_local.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Instructions to run locally:
16+
# Download google container builder: https://github.com/kubernetes-sigs/container-builder-local
17+
# Set you GOOS and GOARCH vars to match your system
18+
# Set OUTPUT to the location to write the directory containing the tar.gz
19+
# $ container-builder-local --config=build/cloudbuild_local.yaml --dryrun=false \
20+
# --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT .
21+
# Release tar will be in $OUTPUT
22+
23+
steps:
24+
- name: "ubuntu"
25+
args: ["mkdir", "-p", "/workspace/_output"]
26+
- name: "golang:1.10-stretch"
27+
args: ["bash", "cmd/kustomize/build/build.sh"]
28+
env:
29+
- 'GOOS=${_GOOS}'
30+
- 'GOARCH=${_GOARCH}'
31+
- 'VERSION=${TAG_NAME}'

demos/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Demos
2+
3+
These demos are covered by presubmit tests.
4+
5+
* [hello world](helloWorld.md) - Deploy multiple
6+
(differently configured) instances of a simple Hello
7+
World server.
8+
9+
* [mysql](mySql.md) - Create a mySql production
10+
configuration from scratch.
11+
12+
* [springboot](springboot.md) - Create a Spring Boot application production
13+
configuration from scratch.

0 commit comments

Comments
 (0)