Last active
August 29, 2017 05:46
-
-
Save taylorsmithgg/5e9e1710f7ee5203645b13599a47d0c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL += -eu | |
BLUE := \033[0;34m | |
GREEN := \033[0;32m | |
RED := \033[0;31m | |
NC := \033[0m | |
export PATH := ~/go/bin:/root/.local/bin:/root/go/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin | |
export DIR_KEY_PAIR := .keypair | |
export DIR_SSL := .cfssl | |
export DIR_KUBECONFIG := .kube | |
# CIDR_PODS: flannel overlay range | |
# - https://coreos.com/flannel/docs/latest/flannel-config.html | |
# | |
# CIDR_SERVICE_CLUSTER: apiserver parameter --service-cluster-ip-range | |
# - http://kubernetes.io/docs/admin/kube-apiserver/ | |
# | |
# CIDR_VPC: vpc subnet | |
# - http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html#VPC_Sizing | |
# - https://www.terraform.io/docs/providers/aws/r/vpc.html#cidr_block | |
# | |
# ∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨ | |
export AWS_REGION ?= us-east-2 | |
export COREOS_CHANNEL ?= stable | |
export COREOS_VM_TYPE ?= hvm | |
# 11 Character Limit | |
export CLUSTER_NAME ?= gstory | |
export AWS_EC2_KEY_NAME ?= kz8s-$(CLUSTER_NAME) | |
export AWS_EC2_KEY_PATH := ${DIR_KEY_PAIR}/${AWS_EC2_KEY_NAME}.pem | |
export INTERNAL_TLD := ${CLUSTER_NAME}.${AWS_REGION}.kz8s | |
export HYPERKUBE_IMAGE ?= quay.io/coreos/hyperkube | |
export HYPERKUBE_TAG ?= v1.7.2_coreos.0 | |
export CIDR_VPC ?= 10.0.0.0/16 | |
export CIDR_PODS ?= 10.2.0.0/16 | |
export CIDR_SERVICE_CLUSTER ?= 10.3.0.0/24 | |
export K8S_SERVICE_IP ?= 10.3.0.1 | |
export K8S_DNS_IP ?= 10.3.0.10 | |
export ETCD_IPS ?= 10.0.10.10,10.0.11.11,10.0.12.12 | |
export PKI_IP ?= 10.0.10.9 | |
# Alternative: | |
# CIDR_PODS ?= "172.15.0.0/16" | |
# CIDR_SERVICE_CLUSTER ?= "172.16.0.0/24" | |
# K8S_SERVICE_IP ?= 172.16.0.1 | |
# K8S_DNS_IP ?= 172.16.0.10 | |
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
.addons: ; @scripts/do-task "initialize add-ons" ./scripts/init-addons | |
.PHONY: azure | |
azure: | |
./azure/scripts/kubeconfig | |
## generate key-pair, variables and then `terraform apply` | |
all: prereqs create-keypair apply | |
@echo "${GREEN}✓ terraform portion of 'make all' has completed ${NC}\n" | |
@$(MAKE) post-terraform | |
.PHONY: post-terraform | |
post-terraform: | |
@$(MAKE) instances | |
@$(MAKE) get-ca | |
@$(MAKE) create-admin-certificate | |
@$(MAKE) create-kubeconfig | |
@$(MAKE) wait-for-cluster | |
helm init | |
@$(MAKE) create-addons | |
kubectl get nodes -o wide | |
kubectl --namespace=kube-system get cs | |
@echo "View nodes:" | |
@echo "% make nodes" | |
@echo "---" | |
@echo "View uninitialized kube-system pods:" | |
@echo "% make pods" | |
@echo "---" | |
@echo "View ec2 instance info:" | |
@echo "% make instances" | |
@echo "---" | |
@echo "Status summaries:" | |
@echo "% make status" | |
@echo "---" | |
@scripts/watch-pods-until | |
@./scripts/push-to-s3 | |
.PHONY: monitoring | |
monitoring: | |
./monitoring/hack/cluster-monitoring/self-hosted-deploy | |
## destroy and remove everything | |
clean: delete-addons destroy delete-keypair | |
@-pkill -f "kubectl proxy" ||: | |
@-rm terraform.tfvars ||: | |
@-rm terraform.tfplan ||: | |
@-rm -rf .terraform ||: | |
@-rm -rf tmp ||: | |
@-rm -rf ${DIR_SSL} ||: | |
@-rm -rf terraform.tfstate ||: | |
@-rm -rf terraform.tfstate.backup ||: | |
## create kube-system addons | |
create-addons: | |
helm init | |
scripts/create-kube-dns-service | |
scripts/create-kube-system-configmap | |
kubectl apply --recursive -f addons | |
helm registry install quay.io/coreos/alb-ingress-controller-helm --name alb --set aws.region=${AWS_REGION} --set clusterName=${CLUSTER_NAME} | |
helm install stable/kube-lego --name tls --set [email protected] --set config.LEGO_URL=https://acme-v01.api.letsencrypt.org/directory | |
helm install charts/stable/external-dns --name external-dns | |
create-admin-certificate: ; @scripts/do-task "create admin certificate" \ | |
scripts/create-admin-certificate | |
create-busybox: ; @scripts/do-task "create busybox test pod" \ | |
kubectl apply -f test/pods/busybox.yml | |
create-kubeconfig: ; @scripts/do-task "create kubeconfig" \ | |
scripts/create-kubeconfig | |
create-monitoring: ; @scripts/do-task "create monitoring" \ | |
monitoring/hack/cluster-monitoring/self-hosted-deploy | |
## delete addons | |
delete-addons: ; @-scripts/delete-addons | |
## start proxy and open kubernetes dashboard | |
dashboard: ; @./scripts/dashboard | |
## get ca certificate | |
get-ca: ; scripts/do-task "get root ca certificate" scripts/get-ca | |
## show instance information | |
instances: ; @scripts/instances | |
## journalctl on etcd1 | |
journal: ; @scripts/ssh "ssh `terraform output etcd1-ip` journalctl -fl" | |
prereqs: ;@scripts/do-task "checking prerequisities" scripts/prereqs | |
## ssh into etcd1 | |
ssh: ; @scripts/ssh "ssh `terraform output etcd1-ip`" | |
## ssh into bastion host | |
ssh-bastion: ; @scripts/ssh | |
## status | |
status: instances ; scripts/status | |
## smoke it | |
test: test-ssl test-route53 test-etcd pods dns | |
## curl relative endpoints and verify requirements | |
wait-for-cluster: ; @scripts/do-task "wait-for-cluster" scripts/wait-for-cluster | |
include makefiles/*.mk | |
.DEFAULT_GOAL := help | |
.PHONY: all clean create-addons create-admin-certificate create-busybox | |
.PHONY: delete-addons get-ca instances journal prereqs ssh ssh-bastion ssl | |
.PHONY: status test wait-for-cluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment