forked from getporter/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.kind
44 lines (37 loc) · 1.36 KB
/
Makefile.kind
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
SHELL = /bin/bash
CLIENT_PLATFORM = $(shell go env GOOS)
CLIENT_ARCH = $(shell go env GOARCH)
# Determine host ip to populate kind config api server details
# https://kind.sigs.k8s.io/docs/user/configuration/#api-server
ifeq ($(CLIENT_PLATFORM),linux)
export CURRENT_HOST_IP=$(shell hostname -i | awk '{print $1; exit}' | cut -d ' ' -f 1)
else
export CURRENT_HOST_IP=$(shell ifconfig en0 | awk '/inet / {print $2; }' | cut -d ' ' -f 2)
endif
## Create file definition for the kind cluster
export KIND_CONFIG_FILE_NAME = kind.config.yaml
define get_kind_config_file
# Remove config file
rm -rf ${KIND_CONFIG_FILE_NAME}
# Define config file
cat << EOF >> ${KIND_CONFIG_FILE_NAME}
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerAddress: "${CURRENT_HOST_IP}"
EOF
endef
export KIND_CLUSTER_FILE_CREATOR = $(value get_kind_config_file)
KIND_VERSION ?= v0.9.0
CLUSTER_NAME = porter
install-kind:
@curl -Lo /tmp/kind https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_VERSION)/kind-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)
@chmod +x /tmp/kind
@sudo mv /tmp/kind /usr/local/bin/kind
create-kind-config-file:; @eval "$$KIND_CLUSTER_FILE_CREATOR"
create-kind-cluster: create-kind-config-file
@kind create cluster \
--name ${CLUSTER_NAME} \
--config ${KIND_CONFIG_FILE_NAME}
delete-kind-cluster:
@kind delete cluster --name ${CLUSTER_NAME}