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