diff --git a/cmd/kinflate/README.md b/cmd/kinflate/README.md index 0b130a4d4..d23a45ea9 100644 --- a/cmd/kinflate/README.md +++ b/cmd/kinflate/README.md @@ -39,6 +39,6 @@ go get k8s.io/kubectl/cmd/kinflate ## Demos - * [hello world one-pager](shortDemo.md) - * [hello world detailed, with instances](longerDemo/README.md) - * [mysql](getting_started.md) + * [hello world one-pager](demoHelloWorldShort.md) + * [hello world detailed, with instances](demoHelloWorldLong/README.md) + * [mysql](demoMySql.md) diff --git a/cmd/kinflate/longerDemo/README.md b/cmd/kinflate/demoHelloWorldLong/README.md similarity index 72% rename from cmd/kinflate/longerDemo/README.md rename to cmd/kinflate/demoHelloWorldLong/README.md index 278752dc5..fee8afc0e 100644 --- a/cmd/kinflate/longerDemo/README.md +++ b/cmd/kinflate/demoHelloWorldLong/README.md @@ -6,12 +6,8 @@ Goal: 1. Customize it. 1. Create two different instances based on the customization. -First install the tool, and define a place to work locally: +First define a place to work: - -``` -go get k8s.io/kubectl/cmd/kinflate -``` ``` DEMO_HOME=$(mktemp -d) @@ -23,6 +19,4 @@ Alternatively, use > DEMO_HOME=~/hello > ``` - - __Next:__ [Clone an Example](clone.md) diff --git a/cmd/kinflate/longerDemo/README_ORDER.txt b/cmd/kinflate/demoHelloWorldLong/README_ORDER.txt similarity index 100% rename from cmd/kinflate/longerDemo/README_ORDER.txt rename to cmd/kinflate/demoHelloWorldLong/README_ORDER.txt diff --git a/cmd/kinflate/longerDemo/clone.md b/cmd/kinflate/demoHelloWorldLong/clone.md similarity index 100% rename from cmd/kinflate/longerDemo/clone.md rename to cmd/kinflate/demoHelloWorldLong/clone.md diff --git a/cmd/kinflate/longerDemo/customize.md b/cmd/kinflate/demoHelloWorldLong/customize.md similarity index 100% rename from cmd/kinflate/longerDemo/customize.md rename to cmd/kinflate/demoHelloWorldLong/customize.md diff --git a/cmd/kinflate/longerDemo/editor.md b/cmd/kinflate/demoHelloWorldLong/editor.md similarity index 100% rename from cmd/kinflate/longerDemo/editor.md rename to cmd/kinflate/demoHelloWorldLong/editor.md diff --git a/cmd/kinflate/longerDemo/manifest.md b/cmd/kinflate/demoHelloWorldLong/manifest.md similarity index 100% rename from cmd/kinflate/longerDemo/manifest.md rename to cmd/kinflate/demoHelloWorldLong/manifest.md diff --git a/cmd/kinflate/longerDemo/overlays/README.md b/cmd/kinflate/demoHelloWorldLong/overlays/README.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/README.md rename to cmd/kinflate/demoHelloWorldLong/overlays/README.md diff --git a/cmd/kinflate/longerDemo/overlays/README_ORDER.txt b/cmd/kinflate/demoHelloWorldLong/overlays/README_ORDER.txt similarity index 100% rename from cmd/kinflate/longerDemo/overlays/README_ORDER.txt rename to cmd/kinflate/demoHelloWorldLong/overlays/README_ORDER.txt diff --git a/cmd/kinflate/longerDemo/overlays/compare.md b/cmd/kinflate/demoHelloWorldLong/overlays/compare.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/compare.md rename to cmd/kinflate/demoHelloWorldLong/overlays/compare.md diff --git a/cmd/kinflate/longerDemo/overlays/deploy.md b/cmd/kinflate/demoHelloWorldLong/overlays/deploy.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/deploy.md rename to cmd/kinflate/demoHelloWorldLong/overlays/deploy.md diff --git a/cmd/kinflate/longerDemo/overlays/production/manifest.md b/cmd/kinflate/demoHelloWorldLong/overlays/production/manifest.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/production/manifest.md rename to cmd/kinflate/demoHelloWorldLong/overlays/production/manifest.md diff --git a/cmd/kinflate/longerDemo/overlays/production/patch.md b/cmd/kinflate/demoHelloWorldLong/overlays/production/patch.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/production/patch.md rename to cmd/kinflate/demoHelloWorldLong/overlays/production/patch.md diff --git a/cmd/kinflate/longerDemo/overlays/staging/manifest.md b/cmd/kinflate/demoHelloWorldLong/overlays/staging/manifest.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/staging/manifest.md rename to cmd/kinflate/demoHelloWorldLong/overlays/staging/manifest.md diff --git a/cmd/kinflate/longerDemo/overlays/staging/patch.md b/cmd/kinflate/demoHelloWorldLong/overlays/staging/patch.md similarity index 100% rename from cmd/kinflate/longerDemo/overlays/staging/patch.md rename to cmd/kinflate/demoHelloWorldLong/overlays/staging/patch.md diff --git a/cmd/kinflate/shortDemo.md b/cmd/kinflate/demoHelloWorldShort.md similarity index 100% rename from cmd/kinflate/shortDemo.md rename to cmd/kinflate/demoHelloWorldShort.md diff --git a/cmd/kinflate/getting_started.md b/cmd/kinflate/demoMySql.md similarity index 78% rename from cmd/kinflate/getting_started.md rename to cmd/kinflate/demoMySql.md index 8fffd5ec6..9ae48fee4 100644 --- a/cmd/kinflate/getting_started.md +++ b/cmd/kinflate/demoMySql.md @@ -6,8 +6,8 @@ production scenario. In the production environment we want: -- MySQL resource names to be prefixed by 'prod-' to make them distinguishable. -- MySQL resources to have 'env: prod' labels so that we can use label selector to query these. +- MySQL resource names to be prefixed by 'prod-'. +- MySQL resources to have 'env: prod' labels. - MySQL to use persistent disk for storing data. ### Download resources @@ -18,8 +18,7 @@ could add to a k8s cluster to run MySql. ``` -DEMO_HOME=$HOME/kinflate_demo/mysql -rm -rf $DEMO_HOME && mkdir -p $DEMO_HOME +DEMO_HOME=$(mktemp -d) cd $DEMO_HOME # Get MySQL configs @@ -30,14 +29,13 @@ done ### Initialize a manifest -A manifest is needed to group these resources together. +A _manifest_ groups these resources together. Create one: ``` -mkdir -p $DEMO_HOME/prod -cd $DEMO_HOME/prod +cd $DEMO_HOME kinflate init ``` @@ -45,7 +43,7 @@ You should now have a file called `Kube-manifest.yaml`: ``` -cat $DEMO_HOME/prod/Kube-manifest.yaml +cat $DEMO_HOME/Kube-manifest.yaml ``` containing something like: @@ -76,17 +74,15 @@ containing something like: > ``` -### Add resources - -Add the resources to the manifest +### Add the resources to the manifest ``` -cd $DEMO_HOME/prod +cd $DEMO_HOME -kinflate add resource ../secret.yaml -kinflate add resource ../service.yaml -kinflate add resource ../deployment.yaml +kinflate add resource secret.yaml +kinflate add resource service.yaml +kinflate add resource deployment.yaml cat Kube-manifest.yaml ``` @@ -97,14 +93,12 @@ cat Kube-manifest.yaml > apiVersion: manifest.k8s.io/v1alpha1 > .... > resources: -> - ../secret.yaml -> - ../service.yaml -> - ../deployment.yaml +> - secret.yaml +> - service.yaml +> - deployment.yaml > ``` -Now we are ready to apply our first customization. - -### NamePrefix Customization +### Name Customization Arrange for the MySQL resources to begin with prefix _prod-_ (since they are meant for the _production_ @@ -112,7 +106,7 @@ environment): ``` -cd $DEMO_HOME/prod +cd $DEMO_HOME kinflate set nameprefix 'prod-' @@ -127,16 +121,14 @@ cat Kube-manifest.yaml > namePrefix: prod- > objectAnnotations: > note: This is a example annotation +> ``` This `namePrefix` directive adds _prod-_ to all resource names. -Run kinflate: - ``` -cd $DEMO_HOME/prod -kinflate inflate -f . +kinflate inflate -f $DEMO_HOME ``` The output should contain: @@ -180,8 +172,8 @@ label, but we can edit `Kube-manifest.yaml` file under ``` -cd $DEMO_HOME/prod -sed -i 's/app: helloworld/app: prod/' Kube-manifest.yaml +sed -i 's/app: helloworld/app: prod/' \ + $DEMO_HOME/Kube-manifest.yaml ``` At this point, running `kinflate inflate -f .` will @@ -197,12 +189,9 @@ environment. So we want to use Persistent Disk in production. Kinflate lets you apply `patches` to the resources. - + ``` -cd $DEMO_HOME/prod - -# Create a patch for persistent-disk.yaml -cat <<'EOF' > persistent-disk.yaml +cat <<'EOF' > $DEMO_HOME/persistent-disk.yaml apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: @@ -216,9 +205,13 @@ spec: gcePersistentDisk: pdName: mysql-persistent-storage EOF +``` -# Edit the manifest file to add the above patch: -cat <<'EOF' >> $DEMO_HOME/prod/Kube-manifest.yaml +Specify the patch file in the manifest: + + +``` +cat <<'EOF' >> $DEMO_HOME/Kube-manifest.yaml patches: - persistent-disk.yaml EOF @@ -242,5 +235,5 @@ create the production environment. ``` -kinflate inflate -f $DEMO_HOME/prod # | kubectl apply -f - +kinflate inflate -f $DEMO_HOME # | kubectl apply -f - ```