├── LICENSE ├── README.md ├── app1 ├── README.md ├── docker-compose.yml ├── hello.dockerapp └── prod.yml ├── app2 ├── README.md ├── bundle.json └── monitoring.dockerapp │ ├── docker-compose.yml │ ├── metadata.yml │ └── parameters.yml ├── app3 ├── README.md ├── bundle.json └── cnab │ ├── Dockerfile │ └── app │ └── run └── app4 ├── README.md ├── bundle.json ├── cnab ├── Dockerfile └── app │ ├── Makefile │ └── charts │ └── alpine │ ├── Chart.yaml │ ├── Dockerfile │ ├── README.md │ ├── templates │ ├── _helpers.tpl │ └── alpine-pod.yaml │ └── values.yaml ├── duffle.toml └── values.toml /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2013-2018 Docker, Inc. 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker App CNAB examples 2 | 3 | This examples in this repository show some basic examples of using `docker-app`, in particular showing some of the CNAB integration details.Feel free to work through each of the examples in order, pick and choose, or modify for your own application. 4 | 5 | * [A simple Compose Hello World example](https://github.com/garethr/docker-app-cnab-examples/tree/master/app1) 6 | * [pushing a CNAB to Docker Hub](https://github.com/garethr/docker-app-cnab-examples/tree/master/app2) 7 | * [CNAB hello world example](https://github.com/garethr/docker-app-cnab-examples/tree/master/app3) 8 | * [Installing a Helm chart using Docker App and CNAB](https://github.com/garethr/docker-app-cnab-examples/tree/master/app4) 9 | 10 | 11 | ## Detailed setup instructions 12 | 13 | Most of this work is moving quickly so official installation instructions and packages will come later. If you need to run these demos you'll need to do some setup. The following instructions should help. 14 | 15 | ### Docker App 16 | 17 | Binaries for both Docker App can be downloaded here: https://github.com/docker/app/releases/ 18 | Take the binaries you need, rename them to `docker-app` (or `docker-app.exe` on Windows) and and put them somewhere in your PATH 19 | 20 | ### Credentials 21 | 22 | `docker-app` uses the new Docker Context functionality which will be available in a future version of Docker. For the moment it bundles this in the `docker-app` CLI itself. 23 | 24 | Docker Desktop exposes a Kubernetes cluster on localhost, but trying to access that cluster on localhost from within a container will fail. This means you probably need to create a separate Kubernetes context. Copy your existing context (in `~/.kube/config`) and then replace the following content: 25 | 26 | ```diff 27 | - server: https://localhost:6445 28 | + server: https://192.168.65.3:6443 29 | ``` 30 | 31 | With that done you should be able to run the following, pointing at the file you just created with the modified server address. 32 | 33 | ```console 34 | $ docker-app context create local --default-stack-orchestrator=kubernetes --description="Local Kubernetes and Docker" --docker-host=unix:///var/run/docker.sock --kubernetes-kubeconfig= 35 | ``` 36 | 37 | You can pass the context to all the `docker-app` commands but that gets tedious quickly. Instead lets set an environment variable pointing at the context you just created. 38 | 39 | ```powershell 40 | $Env:DOCKER_TARGET_CONTEXT="local" 41 | ``` 42 | 43 | ```bash 44 | export DOCKER_TARGET_CONTEXT=local 45 | ``` 46 | 47 | 48 | ### Duffle 49 | 50 | Some examples also use `duffle`, the CNAB reference client. This can be downloaded from https://github.com/deislabs/duffle/releases. Once you have `duffle` installed you should run the following to create various directories and files. 51 | 52 | ```console 53 | duffle init 54 | ``` 55 | 56 | Create a credentials file that points to your modified Kubernetes context. Note that it needs to be a absolute path, so 57 | modify the following as appropriate. Save as `local.yaml` 58 | 59 | ```yaml 60 | name: local 61 | credentials: 62 | - name: kubeconfig 63 | source: 64 | path: C:\Users\garet\.kube\desktop 65 | ``` 66 | 67 | The add those credentials to the duffle store: 68 | 69 | ```console 70 | duffle credentials add local.yaml 71 | ``` 72 | 73 | Additionaly, if you want to create a credentialset suitable for manipulating docker-app based packages with duffle, you can run: 74 | 75 | ``` 76 | docker-app add-credentialset 77 | ``` 78 | 79 | 80 | ### Helm 81 | 82 | Helm installation instructions for the Helm demo can be found on [helm.sh](https://helm.sh/). With Helm installed you'll want to install Tiller with the following: 83 | 84 | ```console 85 | $ helm init 86 | $HELM_HOME has been configured at C:\Users\garet\.helm. 87 | 88 | Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster. 89 | 90 | Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy. 91 | To prevent this, run `helm init` with the --tiller-tls-verify flag. 92 | For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation 93 | Happy Helming! 94 | ``` 95 | -------------------------------------------------------------------------------- /app1/README.md: -------------------------------------------------------------------------------- 1 | ## Requirements 2 | 3 | * Working Docker Desktop install with Kubernetes enabled 4 | * `docker-app` installed 5 | * Source code from this directory 6 | * Create a context with `docker-app context` 7 | * Set the `DOCKER_TARGET_CONTEXT` environment variable 8 | 9 | ## Examples 10 | 11 | Show the details of the application with `inspect` 12 | 13 | ```console 14 | $ docker-app inspect 15 | hello 0.1.0 16 | 17 | Maintained by: garethr 18 | 19 | sample app for DockerCon 20 | 21 | Service (1) Replicas Ports Image 22 | ----------- -------- ----- ----- 23 | hello 1 8765 hashicorp/http-echo:latest 24 | 25 | Parameters (3) Value 26 | -------------- ----- 27 | port 8765 28 | text hello DockerCon 29 | version latest 30 | ``` 31 | 32 | Install the application: 33 | 34 | ``` 35 | docker-app install 36 | ``` 37 | 38 | Show the details of the installation: 39 | 40 | ``` 41 | docker-app status hello 42 | ``` 43 | 44 | Upgrade the installation, demonstrating setting parameters: 45 | 46 | ``` 47 | docker-app upgrade hello --set port=9876 --set text="hello again" 48 | ``` 49 | 50 | Uninstall the application installation: 51 | 52 | 53 | ``` 54 | docker-app uninstall hello 55 | ``` 56 | 57 | Demonstrate building a `bundle.json` for CNAB. 58 | 59 | ```console 60 | $ docker-app bundle 61 | Invocation image "hello:0.1.0-invoc" successfully built 62 | ``` 63 | -------------------------------------------------------------------------------- /app1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | hello: 4 | image: hashicorp/http-echo:${version} 5 | command: ["-text", "${text}"] 6 | ports: 7 | - ${port}:5678 8 | networks: 9 | - backend 10 | -------------------------------------------------------------------------------- /app1/hello.dockerapp: -------------------------------------------------------------------------------- 1 | version: 0.1.0 2 | name: hello 3 | description: sample app for DockerCon 4 | maintainers: 5 | - name: garethr 6 | email: garethr@docker.com 7 | 8 | --- 9 | version: '3.6' 10 | services: 11 | hello: 12 | image: hashicorp/http-echo:${version} 13 | command: ["-text", "${text}"] 14 | ports: 15 | - ${port}:5678 16 | 17 | --- 18 | port: 8765 19 | text: hello DockerCon 20 | version: latest 21 | -------------------------------------------------------------------------------- /app1/prod.yml: -------------------------------------------------------------------------------- 1 | text: Hello Production 2 | version: 1.2 3 | -------------------------------------------------------------------------------- /app2/README.md: -------------------------------------------------------------------------------- 1 | ## Requirements 2 | 3 | * Working Docker Desktop install with Kubernetes enabled 4 | * `docker-app` installed 5 | * Source code from this directory 6 | * Create a context with `docker-app context` 7 | * Set the `DOCKER_TARGET_CONTEXT` environment variable 8 | 9 | 10 | ## Examples 11 | 12 | 13 | First take a look at the application locally: 14 | 15 | ```console 16 | $ docker-app inspect 17 | monitoring 0.1.0 18 | 19 | Maintained by: Gareth Rushgrove 20 | 21 | A basic prometheus stack 22 | 23 | Services (2) Replicas Ports Image 24 | ------------ -------- ----- ----- 25 | prometheus 1 9090 prom/prometheus:latest 26 | alertmanager 1 9093 prom/alertmanager:latest 27 | 28 | Parameters (4) Value 29 | -------------- ----- 30 | ports.alertmanager 9093 31 | ports.prometheus 9090 32 | versions.alertmanager latest 33 | versions.prometheus latest 34 | ``` 35 | 36 | Let's now push that application to Docker Hub for sharing. 37 | 38 | ```console 39 | docker-app push --namespace 40 | ``` 41 | 42 | For the next set of examples we don't need the local files, in fact this could be on another machine entirely. 43 | 44 | Let's inspect the application again: 45 | 46 | ```console 47 | docker-app inspect /monitoring:0.1.0 48 | ``` 49 | 50 | And then install the application from Hub. 51 | 52 | ```console 53 | docker-app install /monitoring:0.1.0 54 | ``` 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app2/bundle.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "monitoring", 3 | "version": "0.1.0", 4 | "description": "A basic prometheus stack", 5 | "maintainers": [ 6 | { 7 | "name": "Gareth Rushgrove", 8 | "email": "garethr@docker.com", 9 | "url": "" 10 | } 11 | ], 12 | "invocationImages": [ 13 | { 14 | "imageType": "docker", 15 | "image": "monitoring:0.1.0-invoc" 16 | } 17 | ], 18 | "images": null, 19 | "actions": { 20 | "inspect": { 21 | "Modifies": false 22 | } 23 | }, 24 | "parameters": { 25 | "docker.kubernetes-namespace": { 26 | "type": "string", 27 | "defaultValue": "", 28 | "required": false, 29 | "metadata": { 30 | "description": "Namespace in which to deploy" 31 | }, 32 | "destination": { 33 | "path": "", 34 | "env": "DOCKER_KUBERNETES_NAMESPACE" 35 | } 36 | }, 37 | "docker.orchestrator": { 38 | "type": "string", 39 | "defaultValue": "", 40 | "allowedValues": [ 41 | "", 42 | "swarm", 43 | "kubernetes" 44 | ], 45 | "required": false, 46 | "metadata": { 47 | "description": "Orchestrator on which to deploy" 48 | }, 49 | "destination": { 50 | "path": "", 51 | "env": "DOCKER_STACK_ORCHESTRATOR" 52 | } 53 | }, 54 | "ports.alertmanager": { 55 | "type": "string", 56 | "defaultValue": "9093", 57 | "required": false, 58 | "metadata": {}, 59 | "destination": { 60 | "path": "", 61 | "env": "docker_param1" 62 | } 63 | }, 64 | "ports.prometheus": { 65 | "type": "string", 66 | "defaultValue": "9090", 67 | "required": false, 68 | "metadata": {}, 69 | "destination": { 70 | "path": "", 71 | "env": "docker_param2" 72 | } 73 | }, 74 | "versions.alertmanager": { 75 | "type": "string", 76 | "defaultValue": "latest", 77 | "required": false, 78 | "metadata": {}, 79 | "destination": { 80 | "path": "", 81 | "env": "docker_param3" 82 | } 83 | }, 84 | "versions.prometheus": { 85 | "type": "string", 86 | "defaultValue": "latest", 87 | "required": false, 88 | "metadata": {}, 89 | "destination": { 90 | "path": "", 91 | "env": "docker_param4" 92 | } 93 | } 94 | }, 95 | "credentials": { 96 | "docker.context": { 97 | "path": "/cnab/app/context.dockercontext", 98 | "env": "" 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /app2/monitoring.dockerapp/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | prometheus: 5 | image: prom/prometheus:${versions.prometheus} 6 | ports: 7 | - ${ports.prometheus}:9090 8 | 9 | alertmanager: 10 | image: prom/alertmanager:${versions.alertmanager} 11 | ports: 12 | - ${ports.alertmanager}:9093 13 | -------------------------------------------------------------------------------- /app2/monitoring.dockerapp/metadata.yml: -------------------------------------------------------------------------------- 1 | version: 0.1.0 2 | name: monitoring 3 | description: A basic prometheus stack 4 | maintainers: 5 | - name: Gareth Rushgrove 6 | email: garethr@docker.com 7 | -------------------------------------------------------------------------------- /app2/monitoring.dockerapp/parameters.yml: -------------------------------------------------------------------------------- 1 | ports: 2 | prometheus: 9090 3 | alertmanager: 9093 4 | versions: 5 | prometheus: latest 6 | alertmanager: latest 7 | -------------------------------------------------------------------------------- /app3/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Requirements 3 | 4 | * Working Docker Desktop install 5 | * `docker-app` installed 6 | * Source code from this directory 7 | * Create a context with `docker-app context` 8 | * Set the `DOCKER_TARGET_CONTEXT` environment variable 9 | 10 | 11 | ## Examples 12 | 13 | Let's install the `hello world` example. Note that this doesn't run any containers on Docker or Kubernetes, it just demonstrates the basic verbs. 14 | 15 | ```console 16 | $ docker-app install bundle.json 17 | Port parameter was set to 8080 18 | Install action 19 | Action install complete for helloworld 20 | ``` 21 | 22 | Grab the status of the application: 23 | 24 | ```console 25 | $ docker-app status helloworld 26 | Port parameter was set to 8080 27 | Status action 28 | Action status complete for helloworld 29 | ``` 30 | 31 | Finally uninstall it: 32 | 33 | ```console 34 | $ docker-app uninstall helloworld 35 | Port parameter was set to 8080 36 | uninstall action 37 | Action uninstall complete for helloworld 38 | ``` 39 | 40 | 41 | Not required, but you can show interop with `duffle` here if you're using it. For example you can list claims in Duffle and it will show applications installed via `docker-app` 42 | 43 | ```console 44 | $ duffle claims list 45 | helloworld 46 | ``` 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app3/bundle.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helloworld", 3 | "version": "0.1.1", 4 | "invocationImages": [ 5 | { 6 | "imageType": "docker", 7 | "image": "cnab/helloworld:0.1.1" 8 | } 9 | ], 10 | "images": [], 11 | "parameters": { 12 | "port": { 13 | "defaultValue": 8080, 14 | "type": "int" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app3/cnab/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | COPY app/run /cnab/app/run 4 | COPY Dockerfile cnab/Dockerfile 5 | 6 | CMD [ "/cnab/app/run" ] -------------------------------------------------------------------------------- /app3/cnab/app/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #set -eo pipefail 4 | 5 | action=$CNAB_ACTION 6 | name=$CNAB_INSTALLATION_NAME 7 | 8 | echo "Port parameter was set to ${CNAB_P_PORT}" 9 | case $action in 10 | install) 11 | echo "Install action" 12 | ;; 13 | uninstall) 14 | echo "uninstall action" 15 | ;; 16 | upgrade) 17 | echo "Upgrade action" 18 | ;; 19 | downgrade) 20 | echo "Downgrade action" 21 | ;; 22 | status) 23 | echo "Status action" 24 | ;; 25 | *) 26 | echo "No action for $action" 27 | ;; 28 | esac 29 | echo "Action $action complete for $name" 30 | -------------------------------------------------------------------------------- /app4/README.md: -------------------------------------------------------------------------------- 1 | ## Requirements 2 | 3 | * Working Docker Desktop install with Kubernetes enabled 4 | * `docker-app` installed 5 | * Source code from this directory 6 | * Create a context with `docker-app context` 7 | * Set the `DOCKER_TARGET_CONTEXT` environment variable 8 | * Helm configured for your Kubernetes cluster 9 | * A `duffle` credential set created 10 | 11 | ## Examples 12 | 13 | 14 | Install the Helm chart example using `docker-app` 15 | 16 | 17 | ``` 18 | $ docker-app install -c local bundle.json 19 | Do install for hellohelm 20 | helm install --namespace hellohelm -n hellohelm /cnab/app/charts/alpine 21 | NAME: hellohelm 22 | LAST DEPLOYED: Wed Nov 28 13:58:22 2018 23 | NAMESPACE: hellohelm 24 | STATUS: DEPLOYED 25 | 26 | RESOURCES: 27 | ==> v1/Pod 28 | NAME AGE 29 | hellohelm-alpine 0s 30 | ``` 31 | 32 | 33 | Check the status of the Helm-based application: 34 | 35 | ```console 36 | $ docker-app status -c local hellohelm 37 | Do Status 38 | helm status hellohelm 39 | LAST DEPLOYED: Wed Nov 28 13:58:22 2018 40 | NAMESPACE: hellohelm 41 | STATUS: DEPLOYED 42 | 43 | RESOURCES: 44 | ==> v1/Pod 45 | NAME AGE 46 | hellohelm-alpine 2m 47 | ``` 48 | 49 | Uninstall the Helm-based application: 50 | 51 | ```console 52 | docker-app uninstall -c local hellohelm 53 | Do Uninstall 54 | helm delete --purge hellohelm 55 | release "hellohelm" deleted 56 | ``` 57 | -------------------------------------------------------------------------------- /app4/bundle.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hellohelm", 3 | "version": "0.1.0", 4 | "invocationImages": [ 5 | { 6 | "imageType": "docker", 7 | "image": "cnab/hellohelm:latest" 8 | } 9 | ], 10 | "images": [ 11 | { 12 | "description": "alpine", 13 | "image": "technosophos/demo2alpine:0.1.0", 14 | "imageType": "docker", 15 | "refs": [ 16 | { 17 | "path": "cnab/app/charts/alpine/values.yaml", 18 | "field": "image.repository" 19 | } 20 | ] 21 | } 22 | ], 23 | "parameters": { 24 | "port": { 25 | "defaultValue": 8080, 26 | "type": "int" 27 | } 28 | }, 29 | "credentials": { 30 | "kubeconfig": { 31 | "path": "/root/.kube/config" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app4/cnab/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cnab/k8sbase:latest 2 | 3 | COPY app/Makefile /cnab/app/Makefile 4 | COPY app/charts /cnab/app/charts -------------------------------------------------------------------------------- /app4/cnab/app/Makefile: -------------------------------------------------------------------------------- 1 | KUBECONFIG=/root/.kube/config 2 | 3 | CNAB_ACTION ?= status 4 | CNAB_INSTALLATION_NAME ?= helmtest 5 | 6 | CNAB_P_HELM_OPTIONS ?= --dry-run --debug 7 | CNAB_P_NAMESPACE ?= hellohelm 8 | 9 | CHART=/cnab/app/charts/alpine 10 | 11 | install: 12 | @echo "Do $(CNAB_ACTION) for $(CNAB_INSTALLATION_NAME)" 13 | helm install --namespace $(CNAB_P_NAMESPACE) -n $(CNAB_INSTALLATION_NAME) $(CHART) 14 | 15 | uninstall: 16 | @echo "Do Uninstall" 17 | helm delete --purge $(CNAB_INSTALLATION_NAME) 18 | 19 | upgrade: 20 | @echo "Do Upgrade" 21 | helm upgrade --namespace $(CNAB_P_NAMESPACE) $(CNAB_INSTALLATION_NAME) $(CHART) 22 | 23 | status: 24 | @echo "Do Status" 25 | helm status $(CNAB_INSTALLATION_NAME) 26 | 27 | .PHONY: install uninstall upgrade status 28 | -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/Chart.yaml: -------------------------------------------------------------------------------- 1 | name: alpine 2 | description: Deploy a basic Alpine Linux pod 3 | version: 0.1.0 4 | home: https://github.com/kubernetes/helm 5 | sources: 6 | - https://github.com/kubernetes/helm 7 | appVersion: 3.3 8 | -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | 3 | CMD ["sleep", "9000"] -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/README.md: -------------------------------------------------------------------------------- 1 | # Alpine: A simple Helm chart 2 | 3 | Run a single pod of Alpine Linux. 4 | 5 | The `templates/` directory contains a very simple pod resource with a 6 | couple of parameters. 7 | 8 | The `values.yaml` file contains the default values for the 9 | `alpine-pod.yaml` template. 10 | 11 | You can install this example using `helm install docs/examples/alpine`. 12 | -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "alpine.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | */}} 13 | {{- define "alpine.fullname" -}} 14 | {{- $name := default .Chart.Name .Values.nameOverride -}} 15 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/templates/alpine-pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: {{ template "alpine.fullname" . }} 5 | labels: 6 | # The "heritage" label is used to track which tool deployed a given chart. 7 | # It is useful for admins who want to see what releases a particular tool 8 | # is responsible for. 9 | heritage: {{ .Release.Service }} 10 | # The "release" convention makes it easy to tie a release to all of the 11 | # Kubernetes resources that were created as part of that release. 12 | release: {{ .Release.Name }} 13 | # This makes it easy to audit chart usage. 14 | chart: {{ .Chart.Name }}-{{ .Chart.Version }} 15 | app: {{ template "alpine.name" . }} 16 | spec: 17 | # This shows how to use a simple value. This will look for a passed-in value called restartPolicy. 18 | restartPolicy: {{ .Values.restartPolicy }} 19 | containers: 20 | - name: waiter 21 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 22 | imagePullPolicy: {{ .Values.image.pullPolicy }} 23 | command: ["/bin/sleep", "9000"] 24 | -------------------------------------------------------------------------------- /app4/cnab/app/charts/alpine/values.yaml: -------------------------------------------------------------------------------- 1 | image: 2 | repository: alpine 3 | tag: 3.3 4 | pullPolicy: IfNotPresent 5 | 6 | restartPolicy: Never 7 | -------------------------------------------------------------------------------- /app4/duffle.toml: -------------------------------------------------------------------------------- 1 | name = "hellohelm" 2 | registry = "cnab" 3 | components = ["cnab"] -------------------------------------------------------------------------------- /app4/values.toml: -------------------------------------------------------------------------------- 1 | greeting = "YO" --------------------------------------------------------------------------------