@@ -33,16 +33,17 @@ Other Services
33
33
* [ hello-go-deploy-amazon-ec2] ( https://github.com/JeffDeCola/hello-go-deploy-amazon-ec2 )
34
34
* [ hello-go-deploy-azure-vm] ( https://github.com/JeffDeCola/hello-go-deploy-azure-vm )
35
35
* [ hello-go-deploy-gce] ( https://github.com/JeffDeCola/hello-go-deploy-gce )
36
-
36
+
37
37
Table of Contents
38
38
39
+ * [ OVERVIEW] ( https://github.com/JeffDeCola/hello-go-deploy-aks#overview )
39
40
* [ PREREQUISITES] ( https://github.com/JeffDeCola/hello-go-deploy-aks#prerequisites )
40
- * [ EXAMPLES ] ( https://github.com/JeffDeCola/hello-go-deploy-aks#examples )
41
- * [ EXAMPLE 1 ] ( https://github.com/JeffDeCola/hello-go-deploy-aks#example-1 )
41
+ * [ SOFTWARE STACK ] ( https://github.com/JeffDeCola/hello-go-deploy-aks#software-stack )
42
+ * [ RUN ] ( https://github.com/JeffDeCola/hello-go-deploy-aks#run )
42
43
* [ STEP 1 - TEST] ( https://github.com/JeffDeCola/hello-go-deploy-aks#step-1---test )
43
44
* [ STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)] ( https://github.com/JeffDeCola/hello-go-deploy-aks#step-2---build-docker-image-via-dockerfile )
44
45
* [ STEP 3 - PUSH (TO DOCKERHUB)] ( https://github.com/JeffDeCola/hello-go-deploy-aks#step-3---push-to-dockerhub )
45
- * [ STEP 4 - DEPLOY] ( https://github.com/JeffDeCola/hello-go-deploy-aks#step-4---deploy )
46
+ * [ STEP 4 - DEPLOY (TO AKS) ] ( https://github.com/JeffDeCola/hello-go-deploy-aks#step-4---deploy-to-aks )
46
47
* [ CONTINUOUS INTEGRATION & DEPLOYMENT] ( https://github.com/JeffDeCola/hello-go-deploy-aks#continuous-integration--deployment )
47
48
48
49
Documentation and Reference
@@ -54,133 +55,134 @@ Documentation and Reference
54
55
[ github webpage] ( https://jeffdecola.github.io/hello-go-deploy-aks/ )
55
56
_ built with
56
57
[ concourse] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/ci-README.md ) _
57
-
58
- ## PREREQUISITES
59
-
60
- For this exercise I used go. Feel free to use a language of your choice,
61
-
62
- * [ go] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/development/languages/go-cheat-sheet )
63
58
64
- To build a docker image you will need docker on your machine,
59
+ ## OVERVIEW
65
60
66
- * [ docker ] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations-tools/orchestration/builds-deployment-containers/docker-cheat-sheet )
61
+ Every 2 seconds this App will print,
67
62
68
- To push a docker image you will need,
69
-
70
- * [ DockerHub account] ( https://hub.docker.com/ )
71
-
72
- To deploy ` aks ` you will need,
63
+ ``` txt
64
+ INFO[0000] Let's Start this!
65
+ Hello everyone, count is: 1
66
+ Hello everyone, count is: 2
67
+ Hello everyone, count is: 3
68
+ etc...
69
+ ```
73
70
74
- * [ microsoft azure kubernetes service (aks) ] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/service-architectures/containers-as-a-service/microsoft-azure-kubernetes-service-cheat-sheet )
71
+ ## PREREQUISITES
75
72
76
- As a bonus, you can use Concourse CI to run the scripts ,
73
+ You will need the following go packages ,
77
74
78
- * [ concourse] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations-tools/continuous-integration-continuous-deployment/concourse-cheat-sheet )
79
- (Optional)
75
+ ``` bash
76
+ go get -u -v github.com/sirupsen/logrus
77
+ go get -u -v github.com/cweill/gotests/...
78
+ ```
80
79
81
- ## EXAMPLES
80
+ ## SOFTWARE STACK
82
81
83
- This repo may have a few examples. We will deploy example 1.
82
+ * DEVELOPMENT
83
+ * [ go] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/development/languages/go-cheat-sheet )
84
+ * OPERATIONS
85
+ * [ concourse/fly] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/continuous-integration-continuous-deployment/concourse-cheat-sheet )
86
+ (optional)
87
+ * [ docker] ( https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/orchestration/builds-deployment-containers/docker-cheat-sheet )
88
+ * SERVICES
89
+ * [ dockerhub] ( https://hub.docker.com/ )
90
+ * azure kubernetes service (aks)
84
91
85
- ### EXAMPLE 1
92
+ ## RUN
86
93
87
- To run from the command line,
94
+ To
95
+ [ run.sh] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/hello-go-deploy-aks-code/run.sh ) ,
88
96
89
97
``` bash
98
+ cd hello-go-deploy-aks-code
90
99
go run main.go
91
100
```
92
101
93
- Every 2 seconds ` hello-go-deploy-aks ` will print:
102
+ To
103
+ [ create-binary.sh] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/hello-go-deploy-aks-code/bin/create-binary.sh ) ,
94
104
95
105
``` bash
96
- Hello everyone, count is: 1
97
- Hello everyone, count is: 2
98
- Hello everyone, count is: 3
99
- etc...
106
+ cd hello-go-deploy-aks-code/bin
107
+ go build -o hello-go ../main.go
108
+ ./hello-go
100
109
```
101
110
111
+ This binary will not be used during a docker build
112
+ since it creates it's own.
113
+
102
114
## STEP 1 - TEST
103
115
104
- Lets unit test the code ,
116
+ To create unit ` _test ` files ,
105
117
106
118
``` bash
107
- go test -cover ./... | tee /test/test_coverage.txt
119
+ cd hello-go-deploy-aks-code
120
+ gotests -w -all main.go
108
121
```
109
122
110
- There is a ` unit-tests.sh ` script to run the unit tests.
111
- There is also a script in the /ci folder to run the unit tests
112
- in concourse.
113
-
114
- ## STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)
115
-
116
- We will be using a multi-stage build using a Dockerfile.
117
- The end result will be a very small docker image around 13MB.
123
+ To run
124
+ [ unit-tests.sh] ( https://github.com/JeffDeCola/hello-go-deploy-aks/tree/master/hello-go-deploy-aks-code/test/unit-tests.sh ) ,
118
125
119
126
``` bash
120
- docker build -f build-push/Dockerfile -t jeffdecola/hello-go-deploy-aks .
127
+ go test -cover ./... | tee test/test_coverage.txt
128
+ cat test/test_coverage.txt
121
129
```
122
130
123
- Obviously, replace ` jeffdecola ` with your DockerHub username.
131
+ ## STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)
124
132
125
- In stage 1, rather than copy a binary into a docker image (because
126
- that can cause issue), the Dockerfile will build the binary in the
133
+ This docker image is built in two stages.
134
+ In ** stage 1** , rather than copy a binary into a docker image (because
135
+ that can cause issues), the Dockerfile will build the binary in the
127
136
docker image.
137
+ In ** stage 2** , the Dockerfile will copy this binary
138
+ and place it into a smaller docker image based
139
+ on ` alpine ` , which is around 13MB.
128
140
129
- If you open the DockerFile you can see it will get the dependencies and
130
- build the binary in go,
141
+ To
142
+ [ build.sh] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/hello-go-deploy-aks-code/build/build.sh )
143
+ with a
144
+ [ Dockerfile] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/hello-go-deploy-aks-code/build/Dockerfile ) ,
131
145
132
146
``` bash
133
- FROM golang:alpine AS builder
134
- RUN go get -d -v
135
- RUN go build -o /go/bin/hello-go-deploy-aks main.go
147
+ cd hello-go-deploy-aks-code/build
148
+ docker build -f Dockerfile -t jeffdecola/hello-go-deploy-aks .
136
149
```
137
150
138
- In stage 2, the Dockerfile will copy the binary created in
139
- stage 1 and place into a smaller docker base image based
140
- on ` alpine ` , which is around 13MB.
141
-
142
- You can check and test your docker image,
151
+ You can check and test this docker image,
143
152
144
153
``` bash
154
+ docker images jeffdecola/hello-go-deploy-aks
145
155
docker run --name hello-go-deploy-aks -dit jeffdecola/hello-go-deploy-aks
146
156
docker exec -i -t hello-go-deploy-aks /bin/bash
147
157
docker logs hello-go-deploy-aks
148
- docker images jeffdecola/ hello-go-deploy-aks:latest
158
+ docker rm -f hello-go-deploy-aks
149
159
```
150
160
151
- There is a ` build-push.sh ` script to build and push to DockerHub.
152
- There is also a script in the /ci folder to build and push
153
- in concourse.
154
-
155
- ## STEP 3 - PUSH (TO DOCKERHUB)
161
+ ## STEP 3 - PUSH (TO PLACEHOLDER)
156
162
157
- Lets push your docker image to DockerHub.
158
-
159
- If you are not logged in, you need to login to dockerhub,
163
+ You must be logged in to DockerHub,
160
164
161
165
``` bash
162
166
docker login
163
167
```
164
168
165
- Once logged in you can push to DockerHub
169
+ To
170
+ [ push.sh] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/hello-go-deploy-aks-code/push/push.sh ) ,
166
171
167
172
``` bash
168
173
docker push jeffdecola/hello-go-deploy-aks
169
174
```
170
175
171
- Check you image at DockerHub. My image is located
172
- [ https://hub.docker.com/r/jeffdecola/hello-go-deploy-aks ] ( https://hub.docker.com/r/jeffdecola/hello-go-deploy-aks ) .
173
-
174
- There is a ` build-push.sh ` script to build and push to DockerHub.
175
- There is also a script in the /ci folder to build and push
176
- in concourse.
176
+ Check the
177
+ [ hello-go-deploy-aks docker image] ( https://hub.docker.com/r/jeffdecola/hello-go-deploy-aks )
178
+ at DockerHub.
177
179
178
- ## STEP 4 - DEPLOY
180
+ ## STEP 4 - DEPLOY (TO AKS)
179
181
180
- tbd
182
+ _ Coming soon. _
181
183
182
184
## CONTINUOUS INTEGRATION & DEPLOYMENT
183
185
184
186
Refer to
185
187
[ ci-README.md] ( https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/ci-README.md )
186
- for how I automated the above process .
188
+ on how I automated the above steps using concourse .
0 commit comments