Skip to content

Commit ca20312

Browse files
committed
major revamp
1 parent 5a280bb commit ca20312

29 files changed

+791
-373
lines changed

.codeclimate.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ plugins:
3535
# - <pattern>
3636
exclude_patterns:
3737
- "docs/"
38+
- "**/*_test.go"

.gitignore

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
# CONCOURSE
22
.credentials.yml
33

4+
# VSCODE
5+
.vscode/
6+
47
# GO
58
coverage.out
69

710
# macOS
811
.DS_Store
912

10-
# Ignore all binaries, but not build.sh
13+
# WINDOWS
14+
*.jpg:Zone.Identifier
15+
16+
# Ignore binaries
1117
**/bin/hello-go
1218

1319
# Ignore test coverage
1420
**/test/test_coverage.txt
1521

16-
# Ignore binary used for build
17-
**/build-push/hello-go
22+
# Ignore binary used for docker build
23+
**/build/hello-go
24+
25+
# SFTP VS CODE EXTENTION
26+
sftp.json

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Jeff DeCola
3+
Copyright (c) 2023 Jeff DeCola
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+75-73
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ Other Services
3333
* [hello-go-deploy-amazon-ec2](https://github.com/JeffDeCola/hello-go-deploy-amazon-ec2)
3434
* [hello-go-deploy-azure-vm](https://github.com/JeffDeCola/hello-go-deploy-azure-vm)
3535
* [hello-go-deploy-gce](https://github.com/JeffDeCola/hello-go-deploy-gce)
36-
36+
3737
Table of Contents
3838

39+
* [OVERVIEW](https://github.com/JeffDeCola/hello-go-deploy-aks#overview)
3940
* [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)
4243
* [STEP 1 - TEST](https://github.com/JeffDeCola/hello-go-deploy-aks#step-1---test)
4344
* [STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)](https://github.com/JeffDeCola/hello-go-deploy-aks#step-2---build-docker-image-via-dockerfile)
4445
* [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)
4647
* [CONTINUOUS INTEGRATION & DEPLOYMENT](https://github.com/JeffDeCola/hello-go-deploy-aks#continuous-integration--deployment)
4748

4849
Documentation and Reference
@@ -54,133 +55,134 @@ Documentation and Reference
5455
[github webpage](https://jeffdecola.github.io/hello-go-deploy-aks/)
5556
_built with
5657
[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)
6358

64-
To build a docker image you will need docker on your machine,
59+
## OVERVIEW
6560

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,
6762

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+
```
7370

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
7572

76-
As a bonus, you can use Concourse CI to run the scripts,
73+
You will need the following go packages,
7774

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+
```
8079

81-
## EXAMPLES
80+
## SOFTWARE STACK
8281

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)
8491

85-
### EXAMPLE 1
92+
## RUN
8693

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),
8896

8997
```bash
98+
cd hello-go-deploy-aks-code
9099
go run main.go
91100
```
92101

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),
94104

95105
```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
100109
```
101110

111+
This binary will not be used during a docker build
112+
since it creates it's own.
113+
102114
## STEP 1 - TEST
103115

104-
Lets unit test the code,
116+
To create unit `_test` files,
105117

106118
```bash
107-
go test -cover ./... | tee /test/test_coverage.txt
119+
cd hello-go-deploy-aks-code
120+
gotests -w -all main.go
108121
```
109122

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),
118125

119126
```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
121129
```
122130

123-
Obviously, replace `jeffdecola` with your DockerHub username.
131+
## STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)
124132

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
127136
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.
128140

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),
131145

132146
```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 .
136149
```
137150

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,
143152

144153
```bash
154+
docker images jeffdecola/hello-go-deploy-aks
145155
docker run --name hello-go-deploy-aks -dit jeffdecola/hello-go-deploy-aks
146156
docker exec -i -t hello-go-deploy-aks /bin/bash
147157
docker logs hello-go-deploy-aks
148-
docker images jeffdecola/hello-go-deploy-aks:latest
158+
docker rm -f hello-go-deploy-aks
149159
```
150160

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)
156162

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,
160164

161165
```bash
162166
docker login
163167
```
164168

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),
166171

167172
```bash
168173
docker push jeffdecola/hello-go-deploy-aks
169174
```
170175

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.
177179

178-
## STEP 4 - DEPLOY
180+
## STEP 4 - DEPLOY (TO AKS)
179181

180-
tbd
182+
_Coming soon._
181183

182184
## CONTINUOUS INTEGRATION & DEPLOYMENT
183185

184186
Refer to
185187
[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.

ci-README.md

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# CONCOURSE CONTINUOUS INTEGRATION
1+
# CONCOURSE CONTINUOUS INTEGRATION & DEPLOYMENT
22

3-
I use concourse ci to,
3+
I use concourse to automate,
44

5-
* Copy and edit `README.md` to `/docs/_includes/README.md` for
5+
* Use README for
66
[GitHub Webpage](https://jeffdecola.github.io/hello-go-deploy-aks/)
77
* TEST code
88
* BUILD docker image
99
* PUSH to dockerhub
10-
* DEPLOY to gce
10+
* DEPLOY to aks
1111
* Alert me of the progress via repo status and slack
1212

1313
## PIPELINE
1414

1515
The concourse
1616
[pipeline.yml](https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/ci/pipeline.yml)
17-
shows the entire ci flow. Visually, it looks like,
17+
shows the entire ci flow,
1818

1919
![IMAGE - hello-go-deploy-aks concourse ci pipeline - IMAGE](docs/pics/hello-go-deploy-aks-pipeline.jpg)
2020

2121
## JOBS, TASKS AND RESOURCE TYPES
2222

23-
The concourse `jobs` and `tasks` are,
23+
Concourse Jobs and Tasks
2424

2525
* `job-readme-github-pages` runs task
2626
[task-readme-github-pages.yml](https://github.com/JeffDeCola/hello-go-deploy-aks/blob/master/ci/tasks/task-readme-github-pages.yml)
@@ -39,21 +39,17 @@ The concourse `jobs` and `tasks` are,
3939
that kicks off shell script
4040
[deploy.sh](https://github.com/JeffDeCola/hello-go-deploy-aks/tree/master/ci/scripts/deploy.sh)
4141

42-
The concourse `resources types` are,
42+
Concourse Resources
4343

4444
* `hello-go-deploy-aks` uses a resource type
45-
[docker-image](https://hub.docker.com/r/concourse/git-resource/)
45+
[docker image](https://hub.docker.com/r/concourse/git-resource/)
4646
to PULL a repo from github
4747
* `resource-dump-to-dockerhub` uses a resource type
48-
[docker-image](https://hub.docker.com/r/concourse/docker-image-resource/)
49-
to PUSH a docker image to dockerhub.
48+
[docker image](https://hub.docker.com/r/concourse/docker-image-resource/)
49+
to PUSH a docker image to dockerhub
5050
* `resource-slack-alert` uses a resource type
5151
[docker image](https://hub.docker.com/r/cfcommunity/slack-notification-resource)
5252
that will notify slack on your progress
5353
* `resource-repo-status` uses a resource type
54-
[docker image](https://hub.docker.com/r/dpb587/github-status-resource)
54+
[docker image](https://hub.docker.com/r/jeffdecola/github-status-resource-clone)
5555
that will update your git status for that particular commit
56-
57-
For more information on using concourse for continuous integration,
58-
refer to my
59-
[concourse-cheat-sheet](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/continuous-integration-continuous-deployment/concourse-cheat-sheet).

ci/destroy-pipeline.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#!/bin/bash
2-
# hello-go-deploy-aks destroy-pipeline.sh
1+
#!/bin/sh
2+
# crypto-miner-manager destroy-pipeline.sh
33

4-
fly -t ci destroy-pipeline --pipeline hello-go-deploy-aks
4+
echo " "
5+
echo "Destroy pipeline on target jeffs-ci-target which is team jeffs-ci-team"
6+
fly --target jeffs-ci-target \
7+
destroy-pipeline \
8+
--pipeline crypto-miner-manager
9+
echo " "

0 commit comments

Comments
 (0)