-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (91 loc) · 2.26 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
102
103
104
105
106
107
108
109
110
111
112
113
IMAGE_NAME := cka-k8s:latest
USER_ID := $(shell id -u ${USER})
GROUP_ID := $(shell id -g ${USER})
MY_IP := $(shell curl -s ifconfig.co)
USER := ${HOME}
PROJECT_FOLDER := /opt/project
DOCKER_RUN := docker run -it --rm \
-v ${PWD}/user/azure:/home/user/.azure/ \
-v ${PWD}/user/ssh:/home/user/.ssh/ \
-v ${PWD}/:${PROJECT_FOLDER} \
-u "${USER_ID}:${GROUP_ID}" \
-w "${PROJECT_FOLDER}" \
${IMAGE_NAME}
init.folders:
mkdir -p ${PWD}/user/azure
mkdir -p ${PWD}/user/ssh
build:
docker build \
--build-arg UID="${USER_ID}" \
--build-arg GID="${GROUP_ID}" \
-f ${PWD}/docker/Dockerfile.alpine \
-t ${IMAGE_NAME} \
.
ssh: init.folders
${DOCKER_RUN} /bin/bash
ssh.cp: init.folders
${DOCKER_RUN} ssh cp
NODE := 1
ssh.node: init.folders
${DOCKER_RUN} ssh node${NODE}
# ##################################
# Virtual Box
vb.cluster:
./src/virtualbox/scripts/1.create_cluster.sh
vb.install_ubuntu:
ifdef node
./src/virtualbox/scripts/2.install_ubuntu.sh ${node}
else
@echo "NEED TO SPECIFY NODE NUMBER"
@echo "make ubuntu node=1"
endif
vb.start:
ifdef node
VBoxManage startvm k8s_node_${node} --type=headless
else
@echo "NEED TO SPECIFY NODE NUMBER"
@echo "make start node=1"
endif
vb.drop:
./src/virtualbox/scripts/4.drop_cluster.sh
vb.vms.list:
VBoxManage list runningvms
vb.vm.info:
VBoxManage showvminfo k8s_node_${node}
# ##################################
# Minikube
# (docker|virtualbox)
MINIKUBE_DRIVER := virtualbox
minikube.start:
minikube start \
--driver=${MINIKUBE_DRIVER} \
--nodes=2 \
--disk-size=10g \
--cpus=2 \
--memory=4g \
--kubernetes-version=v1.25.1 \
--cni=calico \
--container-runtime=cri-o \
-p multivbox
# #######################################
# AZURE NAMESPACE
az.docker:
docker run -it --rm \
-v ${PWD}:/opt/project \
-v ${PWD}/user/azure:/root/.azure \
-v ${PWD}/user/ssh:/root/.ssh \
mcr.microsoft.com/azure-cli:latest
az.install:
pip3 install azure-cli
az.show_sp:
az ad sp list | jq '.[] | {"appDisplayName": .appDisplayName, "appID": .appId}'
az.accounts:
az account list -o json | jq
az.clean_cache:
az cache purge
az.allow_my_ip:
az network nsg rule update \
--nsg-name backend.nsg \
-g k8sCkaTerraform \
-n backend.nsg.22 \
--source-address-prefixes "$(MY_IP)" | jq