Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
docker-makefile-sample
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sample
docker-makefile-sample
Commits
c6568fe4
Commit
c6568fe4
authored
May 01, 2020
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Makefile to 1.2.2
parent
a7bab293
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
47 deletions
+79
-47
Makefile
+54
-39
README.md
+25
-8
No files found.
Makefile
View file @
c6568fe4
# a helper shell script
# a helper shell script
MAKE_VERSION
=
1.2.
1
MAKE_VERSION
=
1.2.
2
define
MAKEFUNCTIONCODE
define
MAKEFUNCTIONCODE
function
hasChanges()
{
function
hasChanges()
{
...
@@ -144,12 +144,25 @@ endif
...
@@ -144,12 +144,25 @@ endif
ifeq
(deploy,$(firstword
$(MAKECMDGOALS)))
ifeq
(deploy,$(firstword
$(MAKECMDGOALS)))
doit
=
true
doit
=
true
endif
endif
ifeq
(show-deploy,$(firstword
$(MAKECMDGOALS)))
doit
=
true
endif
ifeq
(annotate,$(firstword
$(MAKECMDGOALS)))
doit
=
true
endif
ifeq
(rollback,$(firstword
$(MAKECMDGOALS)))
doit
=
true
endif
ifdef
doit
ifdef
doit
# use the rest as arguments for "make xxx"
# use the rest as arguments for "make xxx"
#CMD_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
#CMD_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
# ...and turn them into do-nothing targets
#$(eval $(CMD_ARGS):;@:)
#$(eval $(CMD_ARGS):;@:)
DEPLOYARG
=
-n
$(n)
--context
=
$(c)
ifdef
n
DEPLOYARG
=
-n
$(n)
--context
=
$(c)
else
DEPLOYARG
=
-n
nexpieio
--context
=
$(c)
endif
endif
endif
# ifeq ($(CMD_ARGS),)
# ifeq ($(CMD_ARGS),)
...
@@ -162,7 +175,7 @@ endif
...
@@ -162,7 +175,7 @@ endif
.PHONY
:
pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag show-tag
\
.PHONY
:
pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag show-tag
\
push do-push post-push post-init update-make rmi images deploy
push do-push post-push post-init update-make rmi images deploy
show-deploy annotate rollback
init
:
init
:
@
echo
"
$$
MAKEFUNCTIONCODE"
>
./.make-function
@
echo
"
$$
MAKEFUNCTIONCODE"
>
./.make-function
...
@@ -219,41 +232,6 @@ showtag: init release.conf
...
@@ -219,41 +232,6 @@ showtag: init release.conf
@
.
$(RELEASE_SUPPORT)
;
getVersionWithHash
@
.
$(RELEASE_SUPPORT)
;
getVersionWithHash
@
rm .make-function
@
rm .make-function
# tag-patch-release: init
# VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel)
# tag-patch-release: release.conf tag
# tag-minor-release: init
# VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel)
# tag-minor-release: release.conf tag
# tag-major-release: init
# VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel)
# tag-major-release: release.conf tag
# patch-release: tag-patch-release release
# @echo $(VERSION)
# minor-release: tag-minor-release release
# @echo $(VERSION)
# major-release: tag-major-release release
# @echo $(VERSION)
# tag:
# @echo "$$MAKEFUNCTIONCODE" > ./.make-function
# TAG=$(shell . $(RELEASE_SUPPORT); getTag $(VERSION))
# tag: check-status
# @echo "$$MAKEFUNCTIONCODE" > ./.make-function
# @. $(RELEASE_SUPPORT) ; ! tagExists $(TAG) || (echo "ERROR: tag $(TAG) for version $(VERSION) already tagged in git" >&2 && exit 1) ;
# @. $(RELEASE_SUPPORT) ; setRelease $(VERSION)
# git add .
# git commit -m "bumped to version $(VERSION)" ;
# git tag $(TAG) ;
# @ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi
# @rm .make-function
check-status
:
init
check-status
:
init
@
.
$(RELEASE_SUPPORT)
;
!
hasChanges
||
(
echo
"ERROR: there are still outstanding changes"
>
&2
)
;
@
.
$(RELEASE_SUPPORT)
;
!
hasChanges
||
(
echo
"ERROR: there are still outstanding changes"
>
&2
)
;
@
rm .make-function
@
rm .make-function
...
@@ -286,6 +264,43 @@ env-snippet:
...
@@ -286,6 +264,43 @@ env-snippet:
@
rm nexpieconfig.yaml
@
rm nexpieconfig.yaml
@
rm env-snippet-nexpieconfig.yaml
@
rm env-snippet-nexpieconfig.yaml
show-deploy
:
init release.conf
ifndef
c
@echo
Please
run
make
show-deploy
c
={
context
}
else
kubectl
rollout
history
deployment/$(DEPLOYMENT)
$(DEPLOYARG)
endif
@rm
.make-function
annotate
:
init release.conf
ifndef
c
@echo
Please
run
make
show-deploy
c
={
context
}
a
=
"{annotation text}"
else
ifndef
a
@echo
Please
run
make
show-deploy
c
={
context
}
a
=
"{annotation text}"
else
kubectl
annotate
deployment/$(DEPLOYMENT)
kubernetes.io/
change-cause
=
"
$(a)
"
$(DEPLOYARG)
endif
@rm
.make-function
rollback
:
init release.conf
ifndef
r
@echo
Please
run
make
rollback
r
={
revision
}
c
={
context
}
else
kubectl
rollout
undo
deployment/$(DEPLOYMENT)
--to-revision
=
$(r)
$(DEPLOYARG)
endif
@rm
.make-function
deploy
:
init release.conf
deploy
:
init release.conf
@
cat
k8s/deployment.yaml | sed
"s/{{IMAGE_TAG}}/
$(VERSIONHASH)
/g"
| kubectl apply
-f
-
$(DEPLOYARG)
ifndef
c
@echo Deploy failed
:
Please make deploy with c={context}
else
@cat
k8s/deployment.yaml
|
sed
"s/{{IMAGE_TAG}}/$(VERSIONHASH)/g"
|
kubectl
apply
-f
-
$(DEPLOYARG)
@rm
.make-function
@rm
.make-function
ifdef
a
@kubectl
annotate
deployment/$(DEPLOYMENT)
kubernetes.io/
change-cause
=
"
$(a)
"
$(DEPLOYARG)
endif
endif
README.md
View file @
c6568fe4
...
@@ -138,22 +138,39 @@ $ make env-snippet
...
@@ -138,22 +138,39 @@ $ make env-snippet
หากมีการสร้างไฟล์ deployment.yaml ไว้ในโฟลเดอร์ k8s
หากมีการสร้างไฟล์ deployment.yaml ไว้ในโฟลเดอร์ k8s
สามารถสั่ง deploy ขึ้น kubenetes cluster ได้ด้วยคำสั่ง
สามารถสั่ง deploy ขึ้น kubenetes cluster ได้ด้วยคำสั่ง
ในกรณีที่
ใน yaml ไม่จำเป็นต้องระบุ namespace (เช่นใช้ default)
ในกรณีที่
ต้องการระบุ namespace และ context
```
```
make deploy
make deploy
n=<namespace> c=<context>
```
```
ในกรณีที่ต้องการระบุ namespace
เช่น
```
```
make deploy n=
<namespace>
make deploy n=
nexpie c=minikube
```
```
ในกรณีที่ต้องระบุ namespace และเลือก context
ถ้าไม่ได้พิมพ์ -n จะเซตเป็น nexpieio ให้เป็นค่าปกติ แต่ถ้าเซตก็จะใช้ค่าที่เซต ตัวอย่าง สองคำสั่งนี้เท่ากัน
```
```
make deploy n=<namespace> c=<context>
make deploymennt c=dev n=nexpieio
make deploymennt c=dev
```
```
เช่น
ตั้ง annotation ตอน make deploy ได้เลย ตามตัวอย่าง
```
```
make deploy n=nexpie c=minikube
make deploymennt c=dev a="add user api"
```
ดู deployment history ได้จากคำสั่ง
```
make show-deploy c=dev
```
เซต annotation ของ deploy ล่าสุดบน k8s ได้จากคำสั่งตามตัวอย่าง
```
make annotate c=dev a="add user api"
```
undo deployment ได้จากคำสั่งตามตัวอย่าง
```
make rollback c=dev r=24
```
```
tag ของ image จะอยู่ในรูปแบบนี้ 1.0.1-1-84f08685
tag ของ image จะอยู่ในรูปแบบนี้ 1.0.1-1-84f08685
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment