Skip to content

Commit d05ec16

Browse files
committed
add ingress and nodeport
1 parent 361d13f commit d05ec16

File tree

4 files changed

+146
-86
lines changed

4 files changed

+146
-86
lines changed

.gitlab-ci.yml

+86-86
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
11
stages:
2-
- test
3-
- docs
4-
- build
5-
- docker
2+
# - test
3+
# - docs
4+
# - build
5+
# - docker
66
- deploy
77

8-
variables:
9-
POSTGRES_DB: neoscan_test
10-
POSTGRES_USER: postgres
11-
POSTGRES_PASSWORD: "postgres"
8+
#variables:
9+
# POSTGRES_DB: neoscan_test
10+
# POSTGRES_USER: postgres
11+
# POSTGRES_PASSWORD: "postgres"
1212

1313
before_script:
1414
- export IMAGE_TAG="$CI_PIPELINE_ID-$CI_COMMIT_REF_SLUG"
15-
- export SYNC_REGISTRY_PATH="$CI_REGISTRY_IMAGE/sync:$IMAGE_TAG"
16-
- export API_REGISTRY_PATH="$CI_REGISTRY_IMAGE/api:$IMAGE_TAG"
17-
18-
test:
19-
stage: test
20-
image: bitwalker/alpine-elixir-phoenix:1.7.0
21-
services:
22-
- postgres
23-
cache:
24-
key: test-cache
25-
paths:
26-
- deps/
27-
- _build/
28-
script:
29-
- mix local.rebar --force
30-
- mix local.hex --force
31-
- mix deps.get
32-
- mix format --check-formatted
33-
- mix coveralls.post -u --token "${COVERALLS_REPO_TOKEN}" --branch "${CI_COMMIT_REF_NAME}" --message "${CI_COMMIT_TITLE}" --sha "${CI_COMMIT_SHA}"
34-
- rm -Rf _build/test/lib/neo*
35-
artifacts:
36-
paths:
37-
- apps/neoscan_web/assets/static/docs/api.apib
38-
39-
docs:
40-
stage: docs
41-
image:
42-
name: humangeo/aglio
43-
entrypoint: [""]
44-
script:
45-
- aglio --theme-variables streak --theme-template triple -i apps/neoscan_web/assets/static/docs/api.apib -o apps/neoscan_web/assets/static/docs/index.html
46-
artifacts:
47-
paths:
48-
- apps/neoscan_web/assets/static/docs/index.html
49-
50-
build:
51-
stage: build
52-
image: bitwalker/alpine-elixir-phoenix:1.7.0
53-
cache:
54-
key: build-cache
55-
paths:
56-
- deps/
57-
- _build/
58-
variables:
59-
MIX_ENV: prod
60-
script:
61-
- mix local.rebar --force
62-
- mix local.hex --force
63-
- mix deps.get
64-
- cd apps/neoscan_web/assets && npm install && npm run deploy
65-
- cd ../../.. && mix compile
66-
- mix phx.digest
67-
- mix release --name=neoscan_sync --env=prod
68-
- mix release --name=neoscan_api --env=prod
69-
- mkdir -p export/neoscan_sync && mkdir -p export/neoscan_api
70-
- RELEASE_DIR=`ls -d _build/prod/rel/neoscan_sync/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_sync.tar.gz" -C export/neoscan_sync/
71-
- RELEASE_DIR=`ls -d _build/prod/rel/neoscan_api/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_api.tar.gz" -C export/neoscan_api/
72-
- rm -Rf _build/prod/lib/neo*
73-
artifacts:
74-
paths:
75-
- export
76-
77-
docker:
78-
stage: docker
79-
image: docker:latest
80-
services:
81-
- docker:dind
82-
script:
83-
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
84-
- docker build --build-arg APP=neoscan_sync -t $SYNC_REGISTRY_PATH .
85-
- docker build --build-arg APP=neoscan_api -t $API_REGISTRY_PATH .
86-
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
87-
- docker push $SYNC_REGISTRY_PATH
88-
- docker push $API_REGISTRY_PATH
89-
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $SYNC_REGISTRY_PATH $CI_REGISTRY_IMAGE/sync || true"
90-
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $API_REGISTRY_PATH $CI_REGISTRY_IMAGE/api || true"
91-
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/sync || true"
92-
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/api || true"
15+
- export SYNC_REGISTRY_PATH=registry.gitlab.com/cityofzion/neo-scan/sync:27853432-kubernetes #"$CI_REGISTRY_IMAGE/sync:$IMAGE_TAG"
16+
- export API_REGISTRY_PATH=registry.gitlab.com/cityofzion/neo-scan/api:27853432-kubernetes #"$CI_REGISTRY_IMAGE/api:$IMAGE_TAG"
17+
#
18+
#test:
19+
# stage: test
20+
# image: bitwalker/alpine-elixir-phoenix:1.7.0
21+
# services:
22+
# - postgres
23+
# cache:
24+
# key: test-cache
25+
# paths:
26+
# - deps/
27+
# - _build/
28+
# script:
29+
# - mix local.rebar --force
30+
# - mix local.hex --force
31+
# - mix deps.get
32+
# - mix format --check-formatted
33+
# - mix coveralls.post -u --token "${COVERALLS_REPO_TOKEN}" --branch "${CI_COMMIT_REF_NAME}" --message "${CI_COMMIT_TITLE}" --sha "${CI_COMMIT_SHA}"
34+
# - rm -Rf _build/test/lib/neo*
35+
# artifacts:
36+
# paths:
37+
# - apps/neoscan_web/assets/static/docs/api.apib
38+
#
39+
#docs:
40+
# stage: docs
41+
# image:
42+
# name: humangeo/aglio
43+
# entrypoint: [""]
44+
# script:
45+
# - aglio --theme-variables streak --theme-template triple -i apps/neoscan_web/assets/static/docs/api.apib -o apps/neoscan_web/assets/static/docs/index.html
46+
# artifacts:
47+
# paths:
48+
# - apps/neoscan_web/assets/static/docs/index.html
49+
#
50+
#build:
51+
# stage: build
52+
# image: bitwalker/alpine-elixir-phoenix:1.7.0
53+
# cache:
54+
# key: build-cache
55+
# paths:
56+
# - deps/
57+
# - _build/
58+
# variables:
59+
# MIX_ENV: prod
60+
# script:
61+
# - mix local.rebar --force
62+
# - mix local.hex --force
63+
# - mix deps.get
64+
# - cd apps/neoscan_web/assets && npm install && npm run deploy
65+
# - cd ../../.. && mix compile
66+
# - mix phx.digest
67+
# - mix release --name=neoscan_sync --env=prod
68+
# - mix release --name=neoscan_api --env=prod
69+
# - mkdir -p export/neoscan_sync && mkdir -p export/neoscan_api
70+
# - RELEASE_DIR=`ls -d _build/prod/rel/neoscan_sync/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_sync.tar.gz" -C export/neoscan_sync/
71+
# - RELEASE_DIR=`ls -d _build/prod/rel/neoscan_api/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_api.tar.gz" -C export/neoscan_api/
72+
# - rm -Rf _build/prod/lib/neo*
73+
# artifacts:
74+
# paths:
75+
# - export
76+
#
77+
#docker:
78+
# stage: docker
79+
# image: docker:latest
80+
# services:
81+
# - docker:dind
82+
# script:
83+
# - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
84+
# - docker build --build-arg APP=neoscan_sync -t $SYNC_REGISTRY_PATH .
85+
# - docker build --build-arg APP=neoscan_api -t $API_REGISTRY_PATH .
86+
# - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
87+
# - docker push $SYNC_REGISTRY_PATH
88+
# - docker push $API_REGISTRY_PATH
89+
# - "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $SYNC_REGISTRY_PATH $CI_REGISTRY_IMAGE/sync || true"
90+
# - "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $API_REGISTRY_PATH $CI_REGISTRY_IMAGE/api || true"
91+
# - "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/sync || true"
92+
# - "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/api || true"
9393

9494
staging:
9595
stage: deploy

deploy

+37
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,41 @@ if [ -z "$STAGING" ]; then
8686
kubectl apply -f deployment-sync-coz-testnet-neoscan-io.yaml
8787
kubectl apply -f deployment-api-nex-testnet-neoscan-io.yaml
8888
kubectl apply -f deployment-sync-nex-testnet-neoscan-io.yaml
89+
90+
export WORKLOAD_NAME=api-neoscan-io
91+
export STATIC_IP_NAME=neoscan-io
92+
envsubst < ingress.yaml > ingress-neoscan-io.yaml
93+
envsubst < nodeport.yaml > nodeport-neoscan-io.yaml
94+
95+
export WORKLOAD_NAME=api-neoscan-testnet-io
96+
export STATIC_IP_NAME=neoscan-testnet-io
97+
envsubst < ingress.yaml > ingress-neoscan-testnet-io.yaml
98+
envsubst < nodeport.yaml > nodeport-neoscan-testnet-io.yaml
99+
100+
export WORKLOAD_NAME=api-nex-neoscan-testnet-io
101+
export STATIC_IP_NAME=nex-neoscan-testnet-io
102+
envsubst < ingress.yaml > ingress-nex-neoscan-testnet-io.yaml
103+
envsubst < nodeport.yaml > nodeport-nex-neoscan-testnet-io.yaml
104+
105+
export WORKLOAD_NAME=api-coz-neoscan-testnet-io
106+
export STATIC_IP_NAME=coz-neoscan-testnet-io
107+
envsubst < ingress.yaml > ingress-coz-neoscan-testnet-io.yaml
108+
envsubst < nodeport.yaml > nodeport-coz-neoscan-testnet-io.yaml
109+
110+
kubectl apply -f nodeport-neoscan-io.yaml
111+
kubectl apply -f ingress-neoscan-io.yaml
112+
kubectl apply -f nodeport-neoscan-testnet-io.yaml
113+
kubectl apply -f ingress-neoscan-testnet-io.yaml
114+
kubectl apply -f nodeport-nex-neoscan-testnet-io.yaml
115+
kubectl apply -f ingress-nex-neoscan-testnet-io.yaml
116+
kubectl apply -f nodeport-coz-neoscan-testnet-io.yaml
117+
kubectl apply -f ingress-coz-neoscan-testnet-io.yaml
118+
else
119+
export WORKLOAD_NAME=api-neoscan-io
120+
export STATIC_IP_NAME=staging-neoscan-io
121+
envsubst < ingress.yaml > ingress-staging-neoscan-io.yaml
122+
envsubst < nodeport.yaml > nodeport-staging-neoscan-io.yaml
123+
124+
kubectl apply -f nodeport-staging-neoscan-io.yaml
125+
kubectl apply -f ingress-staging-neoscan-io.yaml
89126
fi

ingress.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: ${STATIC_IP_NAME}
5+
annotations:
6+
kubernetes.io/ingress.global-static-ip-name: "${STATIC_IP_NAME}"
7+
spec:
8+
backend:
9+
serviceName: ${WORKLOAD_NAME}
10+
servicePort: 4000

nodeport.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: ${WORKLOAD_NAME}
5+
spec:
6+
selector:
7+
app: ${WORKLOAD_NAME}
8+
type: NodePort
9+
ports:
10+
- name: http
11+
port: 4000
12+
targetPort: 4000
13+
protocol: TCP

0 commit comments

Comments
 (0)