This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
forked from amazon-archives/aws-app-mesh-inject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
101 lines (86 loc) · 2.84 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
SHELL=/bin/bash -eo pipefail
.DEFAULT_GOAL := build
IMAGE_REGION=${shell aws configure get region}
REPO=${IMAGE_ACCOUNT}.dkr.ecr.${IMAGE_REGION}.amazonaws.com/amazon/aws-app-mesh-inject
VERSION=$(shell cat VERSION)
HASH=$(shell git log --pretty=format:'%H' -n 1)
IMAGE_TAG=${VERSION}
IMAGE_ACCOUNT=${shell aws sts get-caller-identity --query "Account" --output text}
#
# Test
#
.PHONY: test goveralls
test:
go test ./...
goveralls:
go test -coverprofile=coverage.out ./...
${GOPATH}/bin/goveralls -coverprofile=coverage.out -service=travis-ci
#
# Build
#
.PHONY: build push hashtag buildpushhash buildhash pushhash
build:
docker build -t ${REPO}:${IMAGE_TAG} .
push:
$(eval export IMAGE_ACCOUNT)
$(eval export IMAGE_REGION)
$(eval export REPO)
$(eval export IMAGE_TAG)
./scripts/pushImage.sh
hashtag:
$(eval export IMAGE_TAG=${HASH})
buildpushhash: | hashtag build push
buildhash: | hashtag build
pushhash: | hashtag push
ci-test-build:
go test ./...
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o appmeshinject ./cmd/app-mesh-inject/*.go
#
# Appmesh inject deployment
#
.PHONY: deploydev deploydevhash deploy clean
# Uses the image from developer account
deploydev:
$(eval export IMAGE_NAME=${REPO}:${IMAGE_TAG})
$(eval export MESH_NAME)
./scripts/deployInjector.sh
deploydevhash: | hashtag deploydev
# Uses the official image from EKS account.
deploy:
$(eval export MESH_NAME)
./scripts/deployInjector.sh
clean:
kubectl delete namespace appmesh-system
kubectl delete mutatingwebhookconfiguration appmesh-inject
kubectl delete clusterrolebindings appmesh-inject
kubectl delete clusterrole appmesh-inject;
rm -rf ./_output
#
# ECR pull secrets
#
.PHONY: ecrsecrets nssecrets
ecrsecrets:
$(eval export TOKEN=$(shell aws ecr get-authorization-token --region ${REGION} \
--registry-ids 072792469044 \
--output text --query 'authorizationData[].authorizationToken'| \
base64 -D | \
cut -d: -f2))
kubectl delete secret --ignore-not-found inject-ecr-secret -n appmesh-system
@kubectl create secret docker-registry inject-ecr-secret -n appmesh-system\
--docker-server=https://${REPO} \
--docker-username=AWS \
--docker-password="${TOKEN}" \
--docker-email="[email protected]"
kubectl patch deployment appmesh-inject -n appmesh-system -p '$(shell cat ecr-secret-patch.json)'
nssecrets:
$(eval export TOKEN=$(shell aws ecr get-authorization-token --region us-west-2 \
--registry-ids 111345817488 \
--output text --query 'authorizationData[].authorizationToken' | \
base64 -D | \
cut -d: -f2))
kubectl delete secret --ignore-not-found appmesh-ecr-secret -n ${NAMESPACE}
@kubectl create secret docker-registry appmesh-ecr-secret -n ${NAMESPACE} \
--docker-server=https://111345817488.dkr.ecr.us-west-2.amazonaws.com \
--docker-username=AWS \
--docker-password="${TOKEN}" \
--docker-email="[email protected]"