-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (35 loc) · 1.62 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
# __ __
# __ ______ ____ ___ ____ _/ /____ ____ ____/ /
# / / / / __ \/ __ `__ \/ __ `/ __/ _ \/ __ \/ __ /
# / /_/ / /_/ / / / / / / /_/ / /_/ __/ /_/ / /_/ /
# \__, /\____/_/ /_/ /_/\__,_/\__/\___/\____/\__,_/
# /____ matthewdavis.io, holla!
#
include .make/Makefile.inc
NS ?= default
SERVICE_NAME ?= echoserver
APP ?= $(SERVICE_NAME)
SERVICE_PORT ?= 80
HOST ?= echoserver.gcp.streaming-platform.com
CERT_NAME ?= tls-$(HOST)
CERT_FILE ?= tls-$(HOST).crt
KEY_FILE ?= ${HOST}.key
export
install: guard-NS guard-HOST guard-SERVICE_NAME guard-SERVICE_PORT
delete: guard-NS guard-HOST guard-SERVICE_NAME guard-SERVICE_PORT
## Generate and Install TLS Cert
tls: tls-generate tls-secret-create
## Generate a self-signed TLS cert
tls-generate:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $(KEY_FILE) -out $(CERT_FILE) -subj "/CN=$(HOST)/O=$(HOST)"
## Delete TLS Secret
tls-secret-delete:
kubectl --namespace $(NS) delete --ignore-not-found secret $(CERT_NAME)
## Create TLS Secret from Cert
tls-secret-create: tls-secret-delete
kubectl --namespace $(NS) create secret tls $(CERT_NAME) --key $(KEY_FILE) --cert $(CERT_FILE)
## Create htpasswd secret (make htpasswd USERNAME=user PASSWORD=changeme)
htpasswd:
docker run --rm -it appsoa/docker-alpine-htpasswd $(USERNAME) $(PASSWORD) > auth
kubectl --namespace $(NS) delete --ignore-not-found secret/basic-auth
kubectl --namespace $(NS) create secret generic basic-auth --from-file=auth