-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
59 lines (49 loc) · 2.14 KB
/
Justfile
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
local_domain_name := env_var_or_default('LOCAL_DOMAIN_NAME', 'vcap.me')
cluster_name := env_var_or_default('CLUSTER_NAME', 'dev')
kindconfig := justfile_directory() / "kindconfig.yaml"
kubeconfig := "$HOME/.kube/kindconfig"
kubectl := "kubectl --kubeconfig=" + kubeconfig + " --context kind-" + cluster_name
# Print help
@help:
just --list
# Create cert
@create-cert:
mkdir -p certs
mkcert -install
mkcert -cert-file certs/server.crt \
-key-file certs/server.key \
'*.{{local_domain_name}}' '{{local_domain_name}}' localhost 127.0.0.1
# Create cluster
@create-cluster:
# create cluster if it doesnt exist
if ! kind get clusters | grep -q "^{{cluster_name}}$"; then \
kind create cluster --kubeconfig "{{kubeconfig}}" --config "{{kindconfig}}" --name "{{cluster_name}}"; \
fi
# Deploy ingress controller with tls certificate
@deploy-ingress:
# Create tls secret
{{kubectl}} create secret tls localcert --key certs/server.key --cert certs/server.crt \
--dry-run=client -o yaml | {{kubectl}} apply -f -
# Deploy ingress-nginx controller
{{kubectl}} apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
echo "Waiting for ingress-nginx to be ready"
{{kubectl}} wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=90s
# Delete cluster
@delete-cluster:
kind delete cluster --name "{{cluster_name}}"
# Deploy a nginx hello app
@deploy-hello:
{{kubectl}} create deployment hello --image=nginxdemos/hello \
--dry-run=client -o yaml | {{kubectl}} apply -f -
{{kubectl}} create service clusterip hello --tcp=8080:80 \
--dry-run=client -o yaml | {{kubectl}} apply -f -
{{kubectl}} create ingress hello --class=nginx \
--rule="{{local_domain_name}}/hello=hello:8080,tls=localcert" \
--dry-run=client -o yaml | {{kubectl}} apply -f -
echo "Hello application is accessible at https://{{local_domain_name}}/hello"
# Pass through kubectl commands, e.g. just k get pod
@k *command:
{{kubectl}} {{command}}