Skip to content

Commit

Permalink
Merge pull request #313 from batazor/istion
Browse files Browse the repository at this point in the history
Istio
  • Loading branch information
batazor authored Feb 2, 2020
2 parents c02dd2e + 49826bf commit 539431f
Show file tree
Hide file tree
Showing 44 changed files with 820 additions and 294 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
docs
github.com
initialState
ops
*.yml
*.yaml
*.md
Expand Down
58 changes: 43 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
# should not to be changed if you follow GitOps operating procedures.
PROJECT_NAME := shortlink

CI_REGISTRY_IMAGE := batazor/${PROJECT_NAME}
CI_COMMIT_TAG := latest

DOCKER_USERNAME := "batazor"

PATH_TO_UI_NUXT := pkg/ui/nuxt

# Export such that its passed to shell functions for Docker to pick up.
export PROJECT_NAME

Expand All @@ -18,9 +15,7 @@ export PROJECT_NAME
.PHONY: help

help: ## This help
@echo 'Usage: make [TARGET]'
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

# APPLICATION ==========================================================================================================
dep: ## Install dependencies for this project
Expand Down Expand Up @@ -118,45 +113,78 @@ clean: ## Clean artifacts
@docker rmi -f shortlink_shortlink

# DOCKER TASKS =========================================================================================================
CI_REGISTRY_IMAGE := batazor/${PROJECT_NAME}

docker: docker-login docker-build docker-push ## docker login > build > push

docker-login: ## Docker login
@echo docker login as ${DOCKER_USERNAME}
@echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin

# Build the container
docker-build: ## Build the container
@echo docker build image ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
@docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} .
@docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} -f ops/dockerfile/shortlink.Dockerfile .

@echo docker build image ${CI_REGISTRY_IMAGE}-logger:${CI_COMMIT_TAG}
@docker build -t ${CI_REGISTRY_IMAGE}-logger:${CI_COMMIT_TAG} -f ops/dockerfile/logger.Dockerfile .

@echo docker build image ${CI_REGISTRY_IMAGE}-ui-nuxt:${CI_COMMIT_TAG}
@docker build -t ${CI_REGISTRY_IMAGE}-ui-nuxt:${CI_COMMIT_TAG} -f ops/dockerfile/ui-nuxt.Dockerfile .

docker-push: ## Publish the container
@echo docker push image ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
@docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}

# KUBERNETES ===========================================================================================================
PATH_TO_SHORTLINK_CHART := ops/Helm/shortlink
PATH_TO_COMMON_CHART := ops/Helm/common

helm-lint: ## Check Helm chart
@helm lint ops/Helm/shortlink
@helm lint ${PATH_TO_SHORTLINK_CHART}
@helm lint ${PATH_TO_COMMON_CHART}

helm-deploy: ## Deploy Helm chart to default kube-context and default namespace
@echo helm install/update ${PROJECT_NAME}
@helm upgrade ${PROJECT_NAME} ops/Helm/shortlink \
@helm upgrade ${PROJECT_NAME} ${PATH_TO_SHORTLINK_CHART} \
--install \
--force \
--wait

helm-clean: ## Clean artifact from K8S
@helm del ${PROJECT_NAME}

helm-common: ## run common service for
@echo helm install/update common service
@helm upgrade common ${PATH_TO_COMMON_CHART} \
--install \
--force \
--wait

# MINIKUBE =============================================================================================================
minikube-init: docker-build ## run minikube for dev mode
@minikube start --cpus 4 --memory "12288mb" # Start minikube
@eval $(minikube docker-env) # Set docker env
minikube-init: ## run minikube for dev mode
@minikube start \
--cpus 4 \
--memory "16384" \
--extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy\
--extra-config=apiserver.enable-admission-plugins="LimitRanger,NamespaceExists,NamespaceLifecycle,ResourceQuota,ServiceAccount,DefaultStorageClass,MutatingAdmissionWebhook"
@minikube addons enable ingress
@eval $(minikube docker-env) # Set docker env

minikube-update: ## update image to last version
@make docker-build
@make helm-deploy
@eval $(minikube docker-env) # Set docker env
@make docker-build # Build docker images on remote host (minikube)
@make helm-deploy # Deploy shortlink HELM-chart

minikube-down: ## minikube delete
@minikube delete

# ISTIO ================================================================================================================
istio-run: ## Run istio
@istioctl manifest apply --set profile=demo

# UI ===================================================================================================================
PATH_TO_UI_NUXT := pkg/ui/nuxt

nuxt_generate: ## Deploy nuxt UI
@npm --prefix ${PATH_TO_UI_NUXT} install
@npm --prefix ${PATH_TO_UI_NUXT} run generate
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ docker-compose \
+ Helm Chart
+ [pingcap/chaos-meshh](https://github.com/pingcap/chaos-mesh)
+ Minikube
+ Istio

### Gateway

Expand Down Expand Up @@ -130,6 +131,21 @@ docker-compose \
Sometimes a container without a specified ip may occupy a binding address of another service,
which will result in `Address already in use`.

### Kubernetes

##### HELM

+ common - run common tools (ingress)
+ shortlink - run shortlink applications (shortlink, logger, ui)

##### DNS

+ `ui-nuxt.shortlink.minikube`
+ `api.shortlink.minikube`
+ `grafana.minikube`
+ `jaeger.minikube`
+ `prometheus.minikube`

### TRAVIS CI

- DOCKER_PASSWORD
Expand Down
17 changes: 3 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ module github.com/batazor/shortlink
go 1.13

require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/DataDog/zstd v1.4.1 // indirect
github.com/Masterminds/squirrel v1.2.0
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/Shopify/sarama v1.26.0
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cloudevents/sdk-go v1.0.0
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 // indirect
github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 // indirect
github.com/dgraph-io/badger v1.6.0
github.com/dgraph-io/dgo/v2 v2.2.0
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/getsentry/sentry-go v0.4.0
github.com/go-chi/chi v4.0.3+incompatible
github.com/go-chi/cors v1.0.0
Expand All @@ -35,15 +29,10 @@ require (
github.com/jmoiron/sqlx v1.2.0
github.com/lib/pq v1.3.0
github.com/markbates/pkger v0.14.0
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/nats-io/nats.go v1.9.1
github.com/oligot/go-mod-upgrade v0.1.1 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
github.com/opentracing/opentracing-go v1.1.0
github.com/ory/dockertest v3.3.5+incompatible
github.com/ory/dockertest/v3 v3.5.4
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.4.0
Expand All @@ -64,7 +53,7 @@ require (
go.uber.org/goleak v1.0.0
go.uber.org/zap v1.13.0
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d // indirect
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb // indirect
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect
golang.org/x/tools v0.0.0-20191224055732-dd894d0a8a40 // indirect
google.golang.org/genproto v0.0.0-20200128133413-58ce757ed39b
Expand Down
Loading

0 comments on commit 539431f

Please sign in to comment.