Repository: thockin/micro-demos
Branch: master
Commit: 893dccfb54b6
Files: 66
Total size: 63.4 KB
Directory structure:
gitextract_gkio4orz/
├── .github/
│ └── workflows/
│ └── assign.yaml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── cleanup.sh
├── config_maps/
│ ├── configmap.yaml
│ ├── demo.sh
│ └── pod.yaml
├── daemon_sets/
│ ├── daemon.yaml
│ ├── demo.sh
│ ├── split1_color_nodes.sh
│ ├── split1_hit_svc.sh
│ └── svc.yaml
├── demo-namespace.yaml
├── deployments/
│ ├── demo.sh
│ ├── deployment.yaml
│ ├── split1_control.sh
│ ├── split1_hit_svc.sh
│ ├── split1_watch.sh
│ └── svc.yaml
├── example.sh
├── graceful_termination/
│ ├── demo.sh
│ └── pod.yaml
├── init-containers/
│ ├── demo.sh
│ └── pod.yaml
├── jobs/
│ ├── demo.sh
│ └── job.yaml
├── mcs/
│ ├── demo.sh
│ ├── deploy1.yaml
│ ├── deploy2.yaml
│ ├── export.yaml
│ ├── reset.sh
│ ├── svc.yaml
│ ├── udemo.sh
│ └── vars.sh
├── pod_autoscalers/
│ └── demo.sh
├── pods/
│ ├── demo.sh
│ └── pod.yaml
├── pv-provisioning/
│ ├── claim.yaml
│ ├── demo.sh
│ └── pod.yaml
├── quota/
│ ├── demo.sh
│ ├── limits.yaml
│ ├── pod1.yaml
│ ├── pod2.yaml
│ └── quota.yaml
├── replicasets/
│ ├── demo.sh
│ └── rs.yaml
├── replication_controllers/
│ └── demo.sh
├── reset.sh
├── rolling_update/
│ ├── demo.sh
│ ├── rc-v1.yaml
│ ├── rc-v2.yaml
│ ├── split1_hit_svc.sh
│ ├── split1_update.sh
│ └── svc.yaml
├── secrets/
│ ├── demo.sh
│ ├── pod.yaml
│ └── secret.yaml
├── services/
│ ├── demo.sh
│ ├── service.yaml
│ ├── split1_hit_svc.sh
│ └── split1_scale.sh
├── setup.sh
└── util.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/assign.yaml
================================================
name: Assign
on:
issues:
types: [opened, reopened]
pull_request_target:
types: [opened, reopened]
jobs:
assign:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.addAssignees({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ['thockin']
})
================================================
FILE: .gitignore
================================================
# OSX leaves these everywhere on SMB shares
._*
# OSX trash
.DS_Store
# Eclipse files
.classpath
.project
.settings/**
# Emacs save files
*~
\#*\#
.\#*
# Vim-related files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
================================================
FILE: .travis.yml
================================================
sudo: required
services:
- docker
language: go
matrix:
include:
- go: 1.9
install:
- mkdir -p $HOME/gopath/src/k8s.io
- mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/contrib
- hack/install-verify-tools.sh
- export PATH=$GOPATH/bin:$PATH
- hack/for-go-proj.sh install
script:
- hack/verify-all.sh -v
- hack/for-go-proj.sh test
notifications:
irc: "chat.freenode.net#kubernetes-dev"
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
================================================
FILE: README.md
================================================
# Kubernetes micro-demos
This is a collection of highly-targetted demonstrations of Kubernetes features.
The demos are all text-based and automated, making them perfect for customer
meetings, meetups, or just showing off to your colleagues.
## Running the demos
To run these demos you need `pv` and `tmux` installed, and you need `kubectl`
in your PATH.
Some of the demos try to act in faster-than-real time. For best results:
* SSH to your kubernetes-master and set the following flags (in this order):
* kube-controllermanager: --pod-eviction-timeout=10s
Before running a demo, make sure your cluster is demo-ready. The `reset.sh`
script is provided for that.
## Writing new demos
Each demo lives in its own directory. The bulk of the logic lives in
`util.sh`.
Demos should be small and focused - 2 to 3 minutes each.
Demos should be repeatable. Make sure you are not relying on timing effects.
If you need to `sleep`, you might have a problem.
Demos should be self-contained. If you are depending on something being done
before-hand, don't. Do it in the demo script.
Demos should be single-terminal. Use `tmux` to split the window to show
multiple parallel things.
================================================
FILE: cleanup.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/util.sh
desc "Nuke it all"
run "kubectl delete namespace demos"
while kubectl get namespace demos >/dev/null 2>&1; do
run "kubectl get namespace demos"
done
run "kubectl get namespace demos"
run "kubectl get namespaces"
tmux kill-session -t my-session >/dev/null 2>&1
================================================
FILE: config_maps/configmap.yaml
================================================
apiVersion: v1
kind: ConfigMap
metadata:
namespace: demos
name: my-app-config
data:
cfg-version: "93"
min-power: "1"
max-power: "100"
objective: "world domination"
================================================
FILE: config_maps/demo.sh
================================================
#!/bin/bash
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a config map"
run "cat $(relative configmap.yaml)"
run "kubectl --namespace=demos create -f $(relative configmap.yaml)"
desc "Create a pod which uses that config map"
run "cat $(relative pod.yaml)"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
while true; do
run "kubectl --namespace=demos get pod configmaps-demo-pod"
status=$(kubectl --namespace=demos get pod configmaps-demo-pod | tail -1 | awk '{print $3}')
if [ "$status" == "Running" ]; then
break
fi
done
run "kubectl --namespace=demos exec --tty -i configmaps-demo-pod sh"
================================================
FILE: config_maps/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: configmaps-demo-pod
spec:
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- while true; do sleep 3600; done
volumeMounts:
- name: my-config
mountPath: /etc/config
volumes:
- name: my-config
configMap:
name: my-app-config
================================================
FILE: daemon_sets/daemon.yaml
================================================
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
namespace: demos
name: daemons-demo
spec:
template:
metadata:
labels:
demo: daemons
spec:
nodeSelector:
color: red
containers:
- name: hostname
image: k8s.gcr.io/serve_hostname:1.1
================================================
FILE: daemon_sets/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
for NODE in $(kubectl get nodes -o name | cut -f2 -d/); do
kubectl label node $NODE color- --overwrite >/dev/null 2>&1
done
desc "No labels on nodes"
run "kubectl get nodes \\
-o go-template='{{range .items}}{{.metadata.name}}{{\"\t\"}}{{.metadata.labels}}{{\"\n\"}}{{end}}'"
desc "Run a service to front our daemon"
run "cat $(relative svc.yaml)"
run "kubectl --namespace=demos create -f $(relative svc.yaml)"
desc "Run our daemon"
run "cat $(relative daemon.yaml)"
run "kubectl --namespace=demos create -f $(relative daemon.yaml) --validate=false"
run "kubectl --namespace=demos describe ds daemons-demo"
tmux new -d -s my-session \
"$(dirname ${BASH_SOURCE})/split1_color_nodes.sh" \; \
split-window -v -d "$(dirname $BASH_SOURCE)/split1_hit_svc.sh" \; \
attach \;
================================================
FILE: daemon_sets/split1_color_nodes.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
run "" # wait for first input
desc "Color each node"
for NODE in $(kubectl get nodes -o name | grep -v master | cut -f2 -d/); do
run "kubectl label node $NODE color=red"
run "kubectl --namespace=demos describe ds daemons-demo | head"
done
================================================
FILE: daemon_sets/split1_hit_svc.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
IP=$(kubectl --namespace=demos get svc daemon-demo \
-o go-template='{{.spec.clusterIP}}')
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
while true; do \\
curl --connect-timeout 1 -s $IP && echo || echo \"(timeout)\"; \\
sleep 1; \\
done \\
'"
================================================
FILE: daemon_sets/svc.yaml
================================================
apiVersion: v1
kind: Service
metadata:
namespace: demos
name: daemon-demo
spec:
ports:
- port: 80
protocol: TCP
targetPort: 9376
selector:
demo: daemons
================================================
FILE: demo-namespace.yaml
================================================
apiVersion: v1
kind: Namespace
metadata:
name: demos
================================================
FILE: deployments/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a service that fronts any version of this demo"
run "cat $(relative svc.yaml)"
run "kubectl --namespace=demos apply -f $(relative svc.yaml)"
desc "Deploy v1 of our app"
run "cat $(relative deployment.yaml)"
run "kubectl --namespace=demos apply -f $(relative deployment.yaml)"
# The output of describe is too wide, uncomment the following if needed.
# desc "Check it"
# run "kubectl --namespace=demos describe deployment deployment-demo"
tmux new -d -s my-session \
"$(dirname $BASH_SOURCE)/split1_control.sh" \; \
split-window -v -p 66 "$(dirname ${BASH_SOURCE})/split1_hit_svc.sh" \; \
split-window -v "$(dirname ${BASH_SOURCE})/split1_watch.sh v1" \; \
split-window -h -d "$(dirname ${BASH_SOURCE})/split1_watch.sh v2" \; \
select-pane -t 0 \; \
attach \;
================================================
FILE: deployments/deployment.yaml
================================================
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: deployment-demo
namespace: demos
spec:
selector:
matchLabels:
demo: deployment
replicas: 5
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
demo: deployment
version: v1
spec:
containers:
- name: busybox
image: busybox
command: [ "sh", "-c", "while true; do echo $(hostname) v1 > /data/index.html; sleep 60; done" ]
volumeMounts:
- name: content
mountPath: /data
- name: nginx
image: nginx
volumeMounts:
- name: content
mountPath: /usr/share/nginx/html
readOnly: true
volumes:
- name: content
================================================
FILE: deployments/split1_control.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
run "" # wait for first input
desc "Update the deployment"
run "cat $(relative deployment.yaml) | sed 's/ v1/ v2/g' | kubectl --namespace=demos apply -f-"
desc "Rollback the deployment"
run "kubectl --namespace=demos rollout undo deployment deployment-demo"
================================================
FILE: deployments/split1_hit_svc.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
IP=$(kubectl --namespace=demos get svc deployment-demo \
-o go-template='{{.spec.clusterIP}}')
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
while true; do \\
curl --connect-timeout 1 -s $IP; \\
sleep 0.5; \\
done \\
'"
================================================
FILE: deployments/split1_watch.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
target="$1"
while true; do
kubectl --namespace=demos get rs -l demo=deployment \
-o go-template='{{range .items}}{{.metadata.name}} {{.metadata.labels}}{{"\n"}}{{end}}' \
| while read NAME LABELS; do
if echo "$LABELS" | grep -q "$target"; then
trap "exit" INT
while true; do
kubectl --namespace=demos get rs "$NAME" \
-o go-template="$target Desired: {{.spec.replicas}} Running: {{.status.replicas}}{{\"\n\"}}"
sleep 0.3
done
exit 0
fi
done
done
================================================
FILE: deployments/svc.yaml
================================================
apiVersion: v1
kind: Service
metadata:
namespace: demos
name: deployment-demo
spec:
ports:
- port: 80
protocol: TCP
selector:
demo: deployment
================================================
FILE: example.sh
================================================
#!/bin/bash
# Copyright 2024 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.
. $(dirname ${BASH_SOURCE})/util.sh
desc "This is a comment. It will be printed, but not through the typing simulator."
desc "After this it will run a command."
desc "After each command, it will wait for <enter> to proceed."
run "date"
run "sleep 1"
desc_type "This one will be printed through the typing simulator."
run "date"
desc "If you set \$DEMO_RUN_FAST=1, the typing will go faster"
DEMO_RUN_FAST=1
run "echo \"this is a long command which would have taken a while to type out\""
desc "If you set \$DEMO_RUN_SPEED to a value between 1 and 1000, the typing will go slower or faster"
DEMO_RUN_SPEED=5
run "echo \"this is DEMO_RUN_SPEED=5\""
DEMO_RUN_SPEED=25
run "echo \"this is DEMO_RUN_SPEED=25, which is the default\""
DEMO_RUN_SPEED=100
run "echo \"this is DEMO_RUN_SPEED=100, which is fast enough to need more text here\""
desc "If you set \$DEMO_AUTO_RUN=1 it will not wait for input between commands"
DEMO_AUTO_RUN=1
run "echo \"This is the first command\""
run "echo \"This is the second command\""
run "echo \"This is the third command\""
unset DEMO_AUTO_RUN
desc "The output of the last command is in \$DEMO_RUN_STDOUT if you need it"
run "date"
run "echo \"$DEMO_RUN_STDOUT\""
desc "At the end it will wait for one last <enter>."
================================================
FILE: graceful_termination/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a pod"
run "cat $(relative pod.yaml)"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
desc "Hey look, a pod!"
run "kubectl --namespace=demos get pods"
desc "Get the pod's logs"
run "kubectl --namespace=demos logs graceful-demo --follow"
desc "Delete the pod"
run "kubectl --namespace=demos delete pod graceful-demo"
run "kubectl --namespace=demos get pods graceful-demo"
desc "Get the pod's logs"
run "kubectl --namespace=demos logs graceful-demo --follow"
================================================
FILE: graceful_termination/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: graceful-demo
labels:
demo: graceful-termination
spec:
terminationGracePeriodSeconds: 15
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- "trap \"while true; do echo 'self destructing'; sleep 1; done\" SIGTERM; while true; do date; sleep 1; done"
================================================
FILE: init-containers/demo.sh
================================================
#!/bin/bash
# Copyright 2017 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a Pod with init containers"
run "cat $(relative pod.yaml)"
run "kubectl -n demos create -f $(relative pod.yaml)"
desc "See what happened"
run "kubectl -n demos exec -ti init-ctr-demo -c busybox cat /data/file"
desc "Clean up"
run "kubectl -n demos delete pod init-ctr-demo"
================================================
FILE: init-containers/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
name: init-ctr-demo
namespace: demos
spec:
volumes:
- name: data
emptyDir: {}
initContainers:
- name: init-1
image: busybox
command: [ "sh", "-c", "echo start 1 >> /data/file" ]
volumeMounts:
- name: data
mountPath: /data
- name: init-2
image: busybox
command: [ "sh", "-c", "echo start 2 >> /data/file" ]
volumeMounts:
- name: data
mountPath: /data
containers:
- name: busybox
image: busybox
command: [ "sh", "-c", "sleep 1000" ]
volumeMounts:
- name: data
mountPath: /data
================================================
FILE: jobs/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Run some pods in a job"
run "cat $(relative job.yaml)"
run "kubectl --namespace=demos create -f $(relative job.yaml)"
desc "See what we did"
run "kubectl --namespace=demos describe job jobs-demo"
desc "See pods run"
while [ "$(kubectl --namespace=demos get job jobs-demo -o go-template='{{.status.succeeded}}')" != 15 ]; do
run "kubectl --namespace=demos get pods -l demo=jobs"
run "kubectl --namespace=demos describe job jobs-demo"
done
desc "Final status"
run "kubectl --namespace=demos get pods --show-all -l demo=jobs --sort-by='{.status.phase}'"
================================================
FILE: jobs/job.yaml
================================================
apiVersion: extensions/v1beta1
kind: Job
metadata:
name: jobs-demo
namespace: demos
spec:
selector:
matchLabels:
demo: jobs
parallelism: 5
completions: 15
template:
metadata:
labels:
demo: jobs
spec:
containers:
- name: sleep
image: busybox
command: ["sh", "-c", "sleep 5; if [ $((RANDOM % 4)) -eq 0 ]; then exit 1; fi"]
restartPolicy: Never
================================================
FILE: mcs/demo.sh
================================================
#!/bin/bash
. $(dirname ${BASH_SOURCE})/udemo.sh
. $(dirname ${BASH_SOURCE})/vars.sh
GCLOUD="gcloud --project=$PRJ"
K1="kubectl --context=$CTX1"
K2="kubectl --context=$CTX2"
desc "look ma, clusters!"
run "$GCLOUD container clusters list"
desc "they are registered in an environ"
run "$GCLOUD container hub memberships list"
desc "but they are empty"
run "$K1 get ns"
run "$K2 get ns"
desc "make namespaces for the demo"
run "$K1 create ns demo"
run "$K2 create ns demo"
desc "let's deploy a service"
run "cat $(relative deploy1.yaml)"
run "$K1 -n demo apply -f $(relative deploy1.yaml)"
run "$K1 -n demo expose deploy msg --port=80 --target-port=9376"
desc "prove it"
run "$K1 -n demo run -ti --rm --restart=Never --image=busybox shell-$RANDOM -- wget -qO- msg"
desc "now for some fun"
run "$K1 get crd"
desc "export the service and import it into demo2"
run "cat $(relative export.yaml)"
run "$K1 -n demo apply -f $(relative export.yaml)"
desc "see - it got imported"
run "$K1 -n demo get importedservice"
desc "even in the other cluster"
run "$K2 -n demo get importedservice"
desc "here's the WOW"
run "$K2 -n demo run -ti --rm --restart=Never --image=busybox shell-$RANDOM -- wget -qO- 10.255.255.254"
desc "even better"
run "$K2 -n demo run -ti --rm --restart=Never --image=busybox shell-$RANDOM -- wget -qO- msg.demo.svc.supercluster.local"
desc "let's go even farther"
run "cat $(relative deploy2.yaml)"
run "$K2 -n demo apply -f $(relative deploy2.yaml)"
run "$K2 -n demo expose deploy msg --port=80 --target-port=9376"
run "$K2 -n demo apply -f $(relative export.yaml)"
desc "and the coup de grace"
run "$K2 -n demo run -ti --rm --restart=Never --image=busybox shell-$RANDOM -- sh -c \"for i in \\\$(seq 1 10); do wget -qO- msg.demo.svc.supercluster.local; done\""
================================================
FILE: mcs/deploy1.yaml
================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: msg
namespace: demo
spec:
replicas: 1
selector:
matchLabels:
app: msg
template:
metadata:
labels:
app: msg
spec:
containers:
- name: serve-msg
image: thockin/serve-msg
args: [ "hello from cluster 1" ]
================================================
FILE: mcs/deploy2.yaml
================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: msg
namespace: demo
spec:
replicas: 1
selector:
matchLabels:
app: msg
template:
metadata:
labels:
app: msg
spec:
containers:
- name: serve-msg
image: thockin/serve-msg
args: [ "hello from cluster 2" ]
================================================
FILE: mcs/export.yaml
================================================
kind: ServiceExport
apiVersion: net.gke.io/v1alpha1
metadata:
name: msg
namespace: demo
spec:
superclusterIP: 10.255.255.254
================================================
FILE: mcs/reset.sh
================================================
#!/bin/bash
. $(dirname ${BASH_SOURCE})/vars.sh
kubectl --context=$CTX1 delete namespace demo --wait=false
kubectl --context=$CTX2 delete namespace demo --wait=false
================================================
FILE: mcs/svc.yaml
================================================
apiVersion: v1
kind: Service
metadata:
name: msg
namespace: demo
spec:
ports:
- port: 80
targetPort: 9376
selector:
app: msg
================================================
FILE: mcs/udemo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
readonly reset=$(tput sgr0)
readonly green=$(tput bold; tput setaf 2)
readonly yellow=$(tput bold; tput setaf 3)
readonly blue=$(tput bold; tput setaf 6)
readonly timeout=$(if [ "$(uname)" == "Darwin" ]; then echo "1"; else echo "0.1"; fi)
function desc() {
maybe_first_prompt
echo "$blue# $@$reset"
prompt
}
function prompt() {
echo
echo -n "$yellow\$ $reset"
}
started=""
function maybe_first_prompt() {
if [ -z "$started" ]; then
prompt
started=true
fi
}
# After a `run` this variable will hold the stdout of the command that was run.
# If the command was interactive, this will likely be garbage.
DEMO_RUN_STDOUT=""
function run() {
maybe_first_prompt
rate=25
if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000
fi
echo "$green$1$reset" | pv -qL $rate
if [ -n "$DEMO_RUN_FAST" ]; then
sleep 0.5
fi
OFILE="$(mktemp -t $(basename $0).XXXXXX)"
script -eq -c "$1" -f "$OFILE"
r=$?
read -d '' -t "${timeout}" -n 10000 # clear stdin
prompt
if [ -z "$DEMO_AUTO_RUN" ]; then
read -s
fi
DEMO_RUN_STDOUT="$(tail -n +2 $OFILE | sed 's/\r//g')"
return $r
}
function relative() {
for arg; do
echo "$(realpath $(dirname $(which $0)))/$arg" | sed "s|$(realpath $(pwd))|.|"
done
}
trap "echo" EXIT
================================================
FILE: mcs/vars.sh
================================================
#!/bin/bash
PRJ=thockin-dev-2
CTX1="demo1"
CTX2="demo2"
================================================
FILE: pod_autoscalers/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Run some pods under a replication controller"
run "kubectl --namespace=demos run yes-autoscaler-demo \\
--image=busybox \\
--replicas=1 \\
--limits=cpu=100m \\
-o name \\
-- sh -c 'sleep 5; yes > /dev/null'"
WHAT_WAS_RUN="$DEMO_RUN_STDOUT"
desc "Look what I made!"
run "kubectl --namespace=demos describe $WHAT_WAS_RUN"
desc "One pod was created"
run "kubectl --namespace=demos get pods -l run=yes-autoscaler-demo"
desc "Create a pod autoscaler"
run "kubectl --namespace=demos autoscale $WHAT_WAS_RUN --min=1 --max=10 --cpu-percent=25"
desc "Watch pods get created"
while true; do
run "kubectl --namespace=demos describe hpa yes-autoscaler-demo"
run "kubectl --namespace=demos get pods -l run=yes-autoscaler-demo"
done
================================================
FILE: pods/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "There are no running pods"
run "kubectl --namespace=demos get pods"
desc "Create a pod"
run "cat $(relative pod.yaml)"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
desc "Hey look, a pod!"
run "kubectl --namespace=demos get pods"
desc "Get the pod's IP"
run "kubectl --namespace=demos get pod pods-demo -o yaml | grep podIP"
IP=$(kubectl --namespace=demos get pod pods-demo -o yaml \
| grep podIP \
| cut -f2 -d:)
desc "SSH into my cluster and access the pod"
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
for i in \$(seq 1 10); do \\
curl --connect-timeout 1 -s $IP; \\
sleep 1; \\
done\\
'"
================================================
FILE: pods/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: pods-demo
labels:
demo: pods
spec:
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- while true; do (hostname; date) > /data/index.html; sleep 1; done
volumeMounts:
- name: content
mountPath: /data
- name: nginx
image: nginx
volumeMounts:
- name: content
mountPath: /usr/share/nginx/html
readOnly: true
volumes:
- name: content
================================================
FILE: pv-provisioning/claim.yaml
================================================
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: demos
name: pv-provisioning-demo
labels:
demo: pv-provisioning
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi
================================================
FILE: pv-provisioning/demo.sh
================================================
#!/bin/bash
# Copyright 2015 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "There are no claims"
run "kubectl --namespace=demos get pvc"
desc "Create a claim"
run "cat $(relative claim.yaml)"
run "kubectl --namespace=demos create -f $(relative claim.yaml)"
desc "Check it out"
run "kubectl --namespace=demos describe pvc pv-provisioning-demo"
desc "Wait for it to be satisfied"
run "while true; do
X=\$(kubectl --namespace=demos get pvc pv-provisioning-demo);
echo \"\$X\";
echo \$X | grep Bound >/dev/null && break;
sleep 1;
done"
desc "You can see it in gcloud"
run "gcloud compute disks list | grep kubernetes-dynamic"
desc "Create a pod using the claim"
run "cat $(relative pod.yaml)"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
desc "Here's the pod"
run "kubectl --namespace=demos describe pods -l demo=pv-provisioning"
desc "Wait for it to be running"
run "while true; do
X=\$(kubectl --namespace=demos get pods -l demo=pv-provisioning);
echo \"\$X\";
echo \$X | grep Running >/dev/null && break;
sleep 1;
done"
POD=$(kubectl --namespace=demos get pods -l demo=pv-provisioning -o name | cut -d/ -f2)
desc "Shell into it"
run "kubectl --namespace=demos exec --tty -i $POD sh"
desc "Kill the pod"
run "kubectl --namespace=demos delete pods -l demo=pv-provisioning"
run "kubectl --namespace=demos get pods -l demo=pv-provisioning"
desc "The claim still exists"
run "kubectl --namespace=demos describe pvc pv-provisioning-demo"
desc "The disk still exists"
run "gcloud compute disks list | grep kubernetes-dynamic"
desc "Run another pod using the same claim"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
desc "Wait for it to be running"
run "while true; do
X=\$(kubectl --namespace=demos get pods -l demo=pv-provisioning);
echo \"\$X\";
echo \$X | grep Running >/dev/null && break;
sleep 1;
done"
POD=$(kubectl --namespace=demos get pods -l demo=pv-provisioning -o name | cut -d/ -f2)
desc "Shell into the new one"
run "kubectl --namespace=demos exec --tty -i $POD sh"
desc "Tear it down"
run "kubectl --namespace=demos delete pods -l demo=pv-provisioning"
run "kubectl --namespace=demos get pods -l demo=pv-provisioning"
run "kubectl --namespace=demos delete pvc -l demo=pv-provisioning"
run "kubectl --namespace=demos get pvc -l demo=pv-provisioning"
run "kubectl --namespace=demos get pv"
================================================
FILE: pv-provisioning/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
generateName: pv-provisioning-demo-
labels:
demo: pv-provisioning
spec:
terminationGracePeriodSeconds: 0
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- touch /pv/`hostname`; while true; do sleep 3600; done
volumeMounts:
- name: pv
mountPath: /pv
volumes:
- name: pv
persistentVolumeClaim:
claimName: pv-provisioning-demo
================================================
FILE: quota/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "There is no quota"
run "kubectl --namespace=demos get quota"
desc "Install quota"
run "cat $(relative quota.yaml)"
run "kubectl --namespace=demos create -f $(relative quota.yaml)"
run "kubectl --namespace=demos describe quota demo-quota"
desc "Create a large pod - should fail"
run "cat $(relative pod1.yaml)"
run "kubectl --namespace=demos create -f $(relative pod1.yaml)"
run "kubectl --namespace=demos describe quota demo-quota"
desc "Create a pod with no limits - should fail"
run "cat $(relative pod2.yaml)"
run "kubectl --namespace=demos create -f $(relative pod2.yaml)"
run "kubectl --namespace=demos describe quota demo-quota"
desc "There are no default limits"
run "kubectl --namespace=demos get limits"
desc "Set default limits"
run "cat $(relative limits.yaml)"
run "kubectl --namespace=demos create -f $(relative limits.yaml)"
run "kubectl --namespace=demos describe limits demo-limits"
desc "Create a pod with no limits - should succeed now"
run "cat $(relative pod2.yaml)"
run "kubectl --namespace=demos create -f $(relative pod2.yaml)"
run "kubectl --namespace=demos describe quota demo-quota"
================================================
FILE: quota/limits.yaml
================================================
apiVersion: v1
kind: LimitRange
metadata:
name: demo-limits
namespace: demos
spec:
limits:
- type: Container
defaultRequest:
cpu: 100m
memory: 256Mi
================================================
FILE: quota/pod1.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: quota-demo-large
spec:
containers:
- name: hostname
image: k8s.gcr.io/serve_hostname:1.1
resources:
limits:
cpu: 4.1
memory: 4.1Gi
================================================
FILE: quota/pod2.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: quota-demo-unspecified
spec:
containers:
- name: hostname
image: k8s.gcr.io/serve_hostname:1.1
================================================
FILE: quota/quota.yaml
================================================
apiVersion: v1
kind: ResourceQuota
metadata:
name: demo-quota
namespace: demos
spec:
hard:
cpu: 4
memory: 4Gi
================================================
FILE: replicasets/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Run some pods under a replica set"
run "cat $(relative rs.yaml)"
run "kubectl --namespace=demos create -f $(relative rs.yaml) --validate=false"
desc "Look what I made!"
run "kubectl --namespace=demos get replicasets"
desc "These are the pods that were created"
run "kubectl --namespace=demos get pods -l run=hostnames"
trap "" SIGINT
desc "Kill a pod"
VICTIM=$(kubectl --namespace=demos get pods -o name -l run=hostnames | tail -1)
run "kubectl --namespace=demos delete $VICTIM"
run "kubectl --namespace=demos get pods -l run=hostnames"
desc "Check on which nodes the pods are running"
run "kubectl --namespace=demos get pods -l run=hostnames -o wide"
desc "Kill a node"
NODE=$(kubectl --namespace=demos get pods -l run=hostnames -o wide \
| tail -1 \
| awk '{print $NF}')
run "gcloud compute ssh --zone=us-central1-b $NODE --command '\\
sudo shutdown -r now; \\
'"
while true; do
run "kubectl --namespace=demos get node $NODE"
# TODO: It's possible the two runs get different results. Need to get the output of run.
status=$(kubectl --namespace=demos get node $NODE | tail -1 | awk '{print $2}')
if [ "$status" == "NotReady" ]; then
break
fi
done
while true; do
run "kubectl --namespace=demos get pods -l run=hostnames -o wide"
pods_on_restarting_node=$(kubectl --namespace=demos get pods -l run=hostnames -o wide | grep $NODE)
if [ -z "${pods_on_restarting_node}" ]; then
break
fi
done
================================================
FILE: replicasets/rs.yaml
================================================
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
name: hostnames
spec:
replicas: 5
selector:
matchLabels:
run: hostnames
template:
metadata:
labels:
run: hostnames
spec:
containers:
- name: demo
image: k8s.gcr.io/serve_hostname:1.1
================================================
FILE: replication_controllers/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Run some pods under a replication controller"
run "kubectl --namespace=demos run hostnames \\
--image=k8s.gcr.io/serve_hostname:1.1 \\
--replicas=5 \\
-o name"
WHAT_WAS_RUN="$DEMO_RUN_STDOUT"
desc "Look what I made!"
run "kubectl --namespace=demos describe $WHAT_WAS_RUN"
desc "These are the pods that were created"
run "kubectl --namespace=demos get pods -l run=hostnames"
IPS=($(kubectl --namespace=demos get pods -l run=hostnames \
-o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}'))
desc "SSH into my cluster and access the pods"
run "kubectl --namespace=demos get pods -l run=hostnames \\
-o go-template='{{range .items}}{{.status.podIP}}{{\"\\n\"}}{{end}}'"
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
for IP in ${IPS[*]}; do \\
curl --connect-timeout 1 -s \$IP:9376 && echo; \\
done \\
'"
desc "Kill a pod"
VICTIM=$(kubectl --namespace=demos get pods -o name -l run=hostnames | tail -1)
run "kubectl --namespace=demos delete $VICTIM"
run "kubectl --namespace=demos get pods -l run=hostnames"
run "kubectl --namespace=demos describe $WHAT_WAS_RUN"
desc "Kill a node"
NODE=$(kubectl --namespace=demos get pods -l run=hostnames -o wide \
| tail -1 \
| awk '{print $NF}')
run "kubectl --namespace=demos get pods -l run=hostnames -o wide"
run "gcloud compute ssh --zone=us-central1-b $NODE --command '\\
sudo shutdown -r now; \\
'"
while true; do
run "kubectl --namespace=demos get node $NODE"
status=$(kubectl --namespace=demos get node $NODE | tail -1 | awk '{print $2}')
if [ "$status" == "NotReady" ]; then
break
fi
done
run "kubectl --namespace=demos get pods -l run=hostnames -o wide"
run "kubectl --namespace=demos describe $WHAT_WAS_RUN"
================================================
FILE: reset.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/util.sh
kubectl delete namespace demos
while kubectl get namespace demos >/dev/null 2>&1; do
kubectl get namespace demos
done
kubectl apply -f $(relative demo-namespace.yaml)
tmux kill-session -t my-session
================================================
FILE: rolling_update/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a service that fronts any version of this demo"
run "cat $(relative svc.yaml)"
run "kubectl --namespace=demos create -f $(relative svc.yaml)"
desc "Run v1 of our app"
run "cat $(relative rc-v1.yaml)"
run "kubectl --namespace=demos create -f $(relative rc-v1.yaml)"
tmux new -d -s my-session \
"sleep 10; $(dirname ${BASH_SOURCE})/split1_update.sh" \; \
split-window -h -d "$(dirname $BASH_SOURCE)/split1_hit_svc.sh" \; \
attach \;
================================================
FILE: rolling_update/rc-v1.yaml
================================================
apiVersion: v1
kind: ReplicationController
metadata:
namespace: demos
name: update-demo-v1
spec:
replicas: 5
selector:
demo: update
demo-version: v1
template:
metadata:
labels:
demo: update
demo-version: v1
spec:
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- while true; do echo "$(hostname) v1" > /data/index.html; sleep 60; done
volumeMounts:
- name: content
mountPath: /data
- name: nginx
image: nginx
volumeMounts:
- name: content
mountPath: /usr/share/nginx/html
readOnly: true
volumes:
- name: content
================================================
FILE: rolling_update/rc-v2.yaml
================================================
apiVersion: v1
kind: ReplicationController
metadata:
namespace: demos
name: update-demo-v2
spec:
replicas: 5
selector:
demo: update
demo-version: v2
template:
metadata:
labels:
demo: update
demo-version: v2
spec:
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- while true; do echo "$(hostname) v2" > /data/index.html; sleep 60; done
volumeMounts:
- name: content
mountPath: /data
- name: nginx
image: nginx
volumeMounts:
- name: content
mountPath: /usr/share/nginx/html
readOnly: true
volumes:
- name: content
================================================
FILE: rolling_update/split1_hit_svc.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
IP=$(kubectl --namespace=demos get svc update-demo \
-o go-template='{{.spec.clusterIP}}')
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
while true; do \\
curl --connect-timeout 1 -s $IP; \\
sleep 0.5; \\
done \\
'"
================================================
FILE: rolling_update/split1_update.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Do a rolling update to v2"
run "cat $(relative rc-v2.yaml)"
run "kubectl --namespace=demos rolling-update \\
update-demo-v1 -f $(relative rc-v2.yaml) --update-period=5s"
================================================
FILE: rolling_update/svc.yaml
================================================
apiVersion: v1
kind: Service
metadata:
namespace: demos
name: update-demo
spec:
ports:
- port: 80
protocol: TCP
selector:
demo: update
================================================
FILE: secrets/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Create a secret"
run "cat $(relative secret.yaml)"
run "kubectl --namespace=demos create -f $(relative secret.yaml)"
desc "Create a pod which uses that secret"
run "cat $(relative pod.yaml)"
run "kubectl --namespace=demos create -f $(relative pod.yaml)"
while true; do
run "kubectl --namespace=demos get pod secrets-demo"
status=$(kubectl --namespace=demos get pod secrets-demo | tail -1 | awk '{print $3}')
if [ "$status" == "Running" ]; then
break
fi
done
run "kubectl --namespace=demos exec --tty -i secrets-demo sh"
================================================
FILE: secrets/pod.yaml
================================================
apiVersion: v1
kind: Pod
metadata:
namespace: demos
name: secrets-demo
spec:
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- while true; do sleep 3600; done
volumeMounts:
- name: my-password
mountPath: /data
volumes:
- name: my-password
secret:
secretName: my-secret-password
================================================
FILE: secrets/secret.yaml
================================================
apiVersion: v1
kind: Secret
metadata:
namespace: demos
name: my-secret-password
type: opaque
data:
username: dGhvY2tpbgo=
password: eW91IHdpc2gK
================================================
FILE: services/demo.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
desc "Run some pods"
run "kubectl --namespace=demos run hostnames-svc \\
--image=k8s.gcr.io/serve_hostname:1.1 \\
--replicas=5 \\
-o name"
WHAT_WAS_RUN="$DEMO_RUN_STDOUT"
desc "Expose the result as a service"
run "kubectl --namespace=demos expose $WHAT_WAS_RUN \\
--port=80 --target-port=9376"
desc "Have a look at the service"
run "kubectl --namespace=demos describe svc hostnames-svc"
IP=$(kubectl --namespace=demos get svc hostnames-svc \
-o go-template='{{.spec.clusterIP}}')
desc "See what happens when you access the service's IP"
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
for i in \$(seq 1 10); do \\
curl --connect-timeout 1 -s $IP && echo; \\
done \\
'"
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
for i in \$(seq 1 500); do \\
curl --connect-timeout 1 -s $IP && echo; \\
done | sort | uniq -c; \\
'"
tmux new -d -s my-session \
"sleep 10; $(dirname ${BASH_SOURCE})/split1_scale.sh $WHAT_WAS_RUN" \; \
split-window -h -d "$(dirname $BASH_SOURCE)/split1_hit_svc.sh $WHAT_WAS_RUN" \; \
attach \;
================================================
FILE: services/service.yaml
================================================
apiVersion: v1
kind: Service
metadata:
name: hostnames
spec:
ports:
- port: 80
targetPort: 9376
selector:
run: hostnames
================================================
FILE: services/split1_hit_svc.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
IP=$(kubectl --namespace=demos get svc hostnames-svc \
-o go-template='{{.spec.clusterIP}}')
run "gcloud compute ssh --zone=us-central1-b $SSH_NODE --command '\\
while true; do \\
curl --connect-timeout 1 -s $IP && echo; \\
sleep 0.5; \\
done \\
'"
================================================
FILE: services/split1_scale.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/../util.sh
WHAT_WAS_RUN="$1"
desc "Resize the RC and watch the service backends change"
run "kubectl --namespace=demos scale $WHAT_WAS_RUN --replicas=1"
run "kubectl --namespace=demos scale $WHAT_WAS_RUN --replicas=2"
run "kubectl --namespace=demos scale $WHAT_WAS_RUN --replicas=5"
desc "Fire up a cloud load-balancer"
run "kubectl --namespace=demos get svc hostnames-svc -o yaml \\
| sed 's/ClusterIP/LoadBalancer/' \\
| kubectl replace -f -"
while true; do
run "kubectl --namespace=demos get svc hostnames -o yaml | grep loadBalancer -A 4"
if kubectl --namespace=demos get svc hostnames \
-o go-template='{{index (index .status.loadBalancer.ingress 0) "ip"}}' \
>/dev/null 2>&1; then
break
fi
done
================================================
FILE: setup.sh
================================================
#!/bin/bash
# Copyright 2016 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.
. $(dirname ${BASH_SOURCE})/util.sh
desc "The demo namespace does not exist"
run "kubectl get namespaces"
desc "Create a namespace for these demos"
run "cat $(relative demo-namespace.yaml)"
run "kubectl apply -f $(relative demo-namespace.yaml)"
desc "Hey look, a namespace!"
run "kubectl get namespaces"
================================================
FILE: util.sh
================================================
#!/bin/bash
# Copyright 2016 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.
readonly reset=$(tput sgr0)
readonly green=$(tput bold; tput setaf 2)
readonly yellow=$(tput bold; tput setaf 3)
readonly blue=$(tput bold; tput setaf 6)
readonly timeout=$(if [ "$(uname)" == "Darwin" ]; then echo "1"; else echo "0.1"; fi)
function desc() {
maybe_first_prompt
echo -e "$blue# $@$reset"
prompt
}
function desc_type() {
maybe_first_prompt
rate=25
if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000
fi
if [ -n "$DEMO_RUN_SPEED" ]; then
rate=$DEMO_RUN_SPEED
fi
echo -e "$blue# $@$reset" | pv -qL $rate
prompt
}
function prompt() {
echo -n "$yellow\$ $reset"
}
started=""
function maybe_first_prompt() {
if [ -z "$started" ]; then
prompt
started=true
fi
}
# After a `run` this variable will hold the stdout of the command that was run.
# If the command was interactive, this will likely be garbage.
DEMO_RUN_STDOUT=""
function run() {
maybe_first_prompt
rate=25
if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000
fi
if [ -n "$DEMO_RUN_SPEED" ]; then
rate=$DEMO_RUN_SPEED
fi
echo "$green$1$reset" | pv -qL $rate
if [ -n "$DEMO_RUN_FAST" ]; then
sleep 0.5
fi
OFILE="$(mktemp)"
script -eq -c "$1" -f "$OFILE"
r=$?
read -d '' -t "${timeout}" -n 10000 # clear stdin
prompt
if [ -z "$DEMO_AUTO_RUN" ]; then
read -s
fi
DEMO_RUN_STDOUT="$(tail -n +2 $OFILE | head -n -2 | sed 's/\r//g')"
rm $OFILE
return $r
}
function relative() {
for arg; do
echo "$(realpath $(dirname $(which $0)))/$arg" | sed "s|$(realpath $(pwd))|.|"
done
}
SSH_NODE=$(kubectl get nodes | tail -1 | cut -f1 -d' ')
trap "echo" EXIT
gitextract_gkio4orz/ ├── .github/ │ └── workflows/ │ └── assign.yaml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── cleanup.sh ├── config_maps/ │ ├── configmap.yaml │ ├── demo.sh │ └── pod.yaml ├── daemon_sets/ │ ├── daemon.yaml │ ├── demo.sh │ ├── split1_color_nodes.sh │ ├── split1_hit_svc.sh │ └── svc.yaml ├── demo-namespace.yaml ├── deployments/ │ ├── demo.sh │ ├── deployment.yaml │ ├── split1_control.sh │ ├── split1_hit_svc.sh │ ├── split1_watch.sh │ └── svc.yaml ├── example.sh ├── graceful_termination/ │ ├── demo.sh │ └── pod.yaml ├── init-containers/ │ ├── demo.sh │ └── pod.yaml ├── jobs/ │ ├── demo.sh │ └── job.yaml ├── mcs/ │ ├── demo.sh │ ├── deploy1.yaml │ ├── deploy2.yaml │ ├── export.yaml │ ├── reset.sh │ ├── svc.yaml │ ├── udemo.sh │ └── vars.sh ├── pod_autoscalers/ │ └── demo.sh ├── pods/ │ ├── demo.sh │ └── pod.yaml ├── pv-provisioning/ │ ├── claim.yaml │ ├── demo.sh │ └── pod.yaml ├── quota/ │ ├── demo.sh │ ├── limits.yaml │ ├── pod1.yaml │ ├── pod2.yaml │ └── quota.yaml ├── replicasets/ │ ├── demo.sh │ └── rs.yaml ├── replication_controllers/ │ └── demo.sh ├── reset.sh ├── rolling_update/ │ ├── demo.sh │ ├── rc-v1.yaml │ ├── rc-v2.yaml │ ├── split1_hit_svc.sh │ ├── split1_update.sh │ └── svc.yaml ├── secrets/ │ ├── demo.sh │ ├── pod.yaml │ └── secret.yaml ├── services/ │ ├── demo.sh │ ├── service.yaml │ ├── split1_hit_svc.sh │ └── split1_scale.sh ├── setup.sh └── util.sh
Condensed preview — 66 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (71K chars).
[
{
"path": ".github/workflows/assign.yaml",
"chars": 467,
"preview": "name: Assign\n\non:\n issues:\n types: [opened, reopened]\n pull_request_target:\n types: [opened, reopened]\n\njobs:\n "
},
{
"path": ".gitignore",
"chars": 240,
"preview": "# OSX leaves these everywhere on SMB shares\n._*\n\n# OSX trash\n.DS_Store\n\n# Eclipse files\n.classpath\n.project\n.settings/**"
},
{
"path": ".travis.yml",
"chars": 410,
"preview": "sudo: required\n\nservices:\n - docker\n\nlanguage: go\n\nmatrix:\n include:\n - go: 1.9\n\ninstall:\n - mkdir -p $HOME/gopath"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 1193,
"preview": "# Kubernetes micro-demos\n\nThis is a collection of highly-targetted demonstrations of Kubernetes features.\nThe demos are "
},
{
"path": "cleanup.sh",
"chars": 899,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "config_maps/configmap.yaml",
"chars": 176,
"preview": "apiVersion: v1\nkind: ConfigMap\nmetadata:\n namespace: demos\n name: my-app-config\ndata:\n cfg-version: \"93\"\n min-power:"
},
{
"path": "config_maps/demo.sh",
"chars": 640,
"preview": "#!/bin/bash\n\n. $(dirname ${BASH_SOURCE})/../util.sh\n\ndesc \"Create a config map\"\nrun \"cat $(relative configmap.yaml)\"\nrun"
},
{
"path": "config_maps/pod.yaml",
"chars": 349,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: configmaps-demo-pod\nspec:\n containers:\n - name: busybox\n"
},
{
"path": "daemon_sets/daemon.yaml",
"chars": 300,
"preview": "apiVersion: extensions/v1beta1\nkind: DaemonSet\nmetadata:\n namespace: demos\n name: daemons-demo\nspec:\n template:\n m"
},
{
"path": "daemon_sets/demo.sh",
"chars": 1432,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "daemon_sets/split1_color_nodes.sh",
"chars": 887,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "daemon_sets/split1_hit_svc.sh",
"chars": 944,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "daemon_sets/svc.yaml",
"chars": 175,
"preview": "apiVersion: v1\nkind: Service\nmetadata:\n namespace: demos\n name: daemon-demo\nspec:\n ports:\n - port: 80\n protocol: "
},
{
"path": "demo-namespace.yaml",
"chars": 55,
"preview": "apiVersion: v1\nkind: Namespace\nmetadata:\n name: demos\n"
},
{
"path": "deployments/demo.sh",
"chars": 1438,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "deployments/deployment.yaml",
"chars": 804,
"preview": "apiVersion: extensions/v1beta1\nkind: Deployment\nmetadata:\n name: deployment-demo\n namespace: demos\nspec:\n selector:\n "
},
{
"path": "deployments/split1_control.sh",
"chars": 898,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "deployments/split1_hit_svc.sh",
"chars": 920,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "deployments/split1_watch.sh",
"chars": 1163,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "deployments/svc.yaml",
"chars": 161,
"preview": "apiVersion: v1\nkind: Service\nmetadata:\n namespace: demos\n name: deployment-demo\nspec:\n ports:\n - port: 80\n protoc"
},
{
"path": "example.sh",
"chars": 1849,
"preview": "#!/bin/bash\n# Copyright 2024 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "graceful_termination/demo.sh",
"chars": 1129,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "graceful_termination/pod.yaml",
"chars": 356,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: graceful-demo\n labels:\n demo: graceful-termination\nspe"
},
{
"path": "init-containers/demo.sh",
"chars": 929,
"preview": "#!/bin/bash\n# Copyright 2017 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "init-containers/pod.yaml",
"chars": 598,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n name: init-ctr-demo\n namespace: demos\nspec:\n volumes:\n - name: data\n emptyDir"
},
{
"path": "jobs/demo.sh",
"chars": 1202,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "jobs/job.yaml",
"chars": 420,
"preview": "apiVersion: extensions/v1beta1\nkind: Job\nmetadata:\n name: jobs-demo\n namespace: demos\nspec:\n selector:\n matchLabel"
},
{
"path": "mcs/demo.sh",
"chars": 1784,
"preview": "#!/bin/bash\n\n. $(dirname ${BASH_SOURCE})/udemo.sh\n. $(dirname ${BASH_SOURCE})/vars.sh\n\nGCLOUD=\"gcloud --project=$PRJ\"\nK1"
},
{
"path": "mcs/deploy1.yaml",
"chars": 324,
"preview": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: msg\n namespace: demo\nspec:\n replicas: 1\n selector:\n matchLa"
},
{
"path": "mcs/deploy2.yaml",
"chars": 324,
"preview": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: msg\n namespace: demo\nspec:\n replicas: 1\n selector:\n matchLa"
},
{
"path": "mcs/export.yaml",
"chars": 131,
"preview": "kind: ServiceExport\napiVersion: net.gke.io/v1alpha1\nmetadata:\n name: msg\n namespace: demo\nspec:\n superclusterIP: 10.2"
},
{
"path": "mcs/reset.sh",
"chars": 168,
"preview": "#!/bin/bash\n\n. $(dirname ${BASH_SOURCE})/vars.sh\n\nkubectl --context=$CTX1 delete namespace demo --wait=false\nkubectl --c"
},
{
"path": "mcs/svc.yaml",
"chars": 143,
"preview": "apiVersion: v1\nkind: Service\nmetadata:\n name: msg\n namespace: demo\nspec:\n ports:\n - port: 80\n targetPort: 9376\n "
},
{
"path": "mcs/udemo.sh",
"chars": 1931,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "mcs/vars.sh",
"chars": 57,
"preview": "#!/bin/bash\n\nPRJ=thockin-dev-2\nCTX1=\"demo1\"\nCTX2=\"demo2\"\n"
},
{
"path": "pod_autoscalers/demo.sh",
"chars": 1397,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "pods/demo.sh",
"chars": 1327,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "pods/pod.yaml",
"chars": 484,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: pods-demo\n labels:\n demo: pods\nspec:\n containers:\n -"
},
{
"path": "pv-provisioning/claim.yaml",
"chars": 296,
"preview": "apiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n namespace: demos\n name: pv-provisioning-demo\n labels:\n demo:"
},
{
"path": "pv-provisioning/demo.sh",
"chars": 2977,
"preview": "#!/bin/bash\n# Copyright 2015 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "pv-provisioning/pod.yaml",
"chars": 454,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n generateName: pv-provisioning-demo-\n labels:\n demo: pv-provi"
},
{
"path": "quota/demo.sh",
"chars": 1761,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "quota/limits.yaml",
"chars": 173,
"preview": "apiVersion: v1\nkind: LimitRange\nmetadata:\n name: demo-limits\n namespace: demos\nspec:\n limits:\n - type: Container\n "
},
{
"path": "quota/pod1.yaml",
"chars": 227,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: quota-demo-large\nspec:\n containers:\n - name: hostname\n "
},
{
"path": "quota/pod2.yaml",
"chars": 165,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: quota-demo-unspecified\nspec:\n containers:\n - name: hostn"
},
{
"path": "quota/quota.yaml",
"chars": 124,
"preview": "apiVersion: v1\nkind: ResourceQuota\nmetadata:\n name: demo-quota\n namespace: demos\nspec:\n hard:\n cpu: 4\n memory: "
},
{
"path": "replicasets/demo.sh",
"chars": 2130,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "replicasets/rs.yaml",
"chars": 304,
"preview": "apiVersion: extensions/v1beta1\nkind: ReplicaSet\nmetadata:\n name: hostnames \nspec:\n replicas: 5 \n selector:\n matchL"
},
{
"path": "replication_controllers/demo.sh",
"chars": 2448,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "reset.sh",
"chars": 838,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "rolling_update/demo.sh",
"chars": 1098,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "rolling_update/rc-v1.yaml",
"chars": 720,
"preview": "apiVersion: v1\nkind: ReplicationController\nmetadata:\n namespace: demos\n name: update-demo-v1\nspec:\n replicas: 5\n sel"
},
{
"path": "rolling_update/rc-v2.yaml",
"chars": 720,
"preview": "apiVersion: v1\nkind: ReplicationController\nmetadata:\n namespace: demos\n name: update-demo-v2\nspec:\n replicas: 5\n sel"
},
{
"path": "rolling_update/split1_hit_svc.sh",
"chars": 916,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "rolling_update/split1_update.sh",
"chars": 820,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "rolling_update/svc.yaml",
"chars": 153,
"preview": "apiVersion: v1\nkind: Service\nmetadata:\n namespace: demos\n name: update-demo\nspec:\n ports:\n - port: 80\n protocol: "
},
{
"path": "secrets/demo.sh",
"chars": 1192,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "secrets/pod.yaml",
"chars": 348,
"preview": "apiVersion: v1\nkind: Pod\nmetadata:\n namespace: demos\n name: secrets-demo\nspec:\n containers:\n - name: busybox\n ima"
},
{
"path": "secrets/secret.yaml",
"chars": 153,
"preview": "apiVersion: v1\nkind: Secret\nmetadata:\n namespace: demos\n name: my-secret-password\ntype: opaque\ndata:\n username: dGhvY"
},
{
"path": "services/demo.sh",
"chars": 1771,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "services/service.yaml",
"chars": 142,
"preview": "apiVersion: v1\nkind: Service\nmetadata:\n name: hostnames \nspec:\n ports:\n - port: 80\n targetPort: 9376\n selecto"
},
{
"path": "services/split1_hit_svc.sh",
"chars": 926,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "services/split1_scale.sh",
"chars": 1376,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "setup.sh",
"chars": 907,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "util.sh",
"chars": 2306,
"preview": "#!/bin/bash\n# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
}
]
About this extraction
This page contains the full source code of the thockin/micro-demos GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 66 files (63.4 KB), approximately 18.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.