Verified Commit b41984c2 authored by Dmytro Bogatov's avatar Dmytro Bogatov 💕

Fix #16.

parent 48748b08
Pipeline #3036 failed with stages
in 8 seconds
......@@ -15,3 +15,5 @@ infra/sources/gitlab-runner/config.yaml
infra/terraform/spaces/
infra/spaces-buffer
docker/out
stages:
- build
- deploy
build-image:
stage: build
script:
- docker build -t registry.dbogatov.org/dbogatov/setup-manager .
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.dbogatov.org
- docker push registry.dbogatov.org/dbogatov/setup-manager
tags:
- shell
only:
- master
deploy-latest:
image: dbogatov/docker-images:k8s-deployer-latest
stage: deploy
......
FROM dbogatov/docker-images:k8s-deployer-latest
LABEL maintainer="Dmytro Bogatov <dmytro@dbogatov.org>"
COPY ./service /service
COPY generate-review-app.sh /
#!/bin/bash
set -e
# Ensure that the CWD is set to script's location
cd "${0%/*}"
CWD=$(pwd)
usage () {
printf "usage: $0 <name> <image> <url>\n"
exit 1;
}
if ! [ $# -eq 3 ]
then
usage
fi
NAME=$1
IMAGE=$2
URL=$3
echo "Generating $NAME configs..."
rm -rf ./out
mkdir -p ./out
cp service/{service,deployment,ingress}.yaml ./out
creds="--creds=dbogatov:$DOCKERPASS"
if [[ $IMAGE = *"registry.hub.docker.com"* ]]; then
creds=""
fi
digest=$(skopeo inspect $creds docker://$IMAGE | jq '.Digest')
digest="${digest%\"}"
digest="${digest#\"}"
IMAGE=${IMAGE%:*}@$digest
sed -i -e "s#__IMAGE__#$IMAGE#g" ./out/{service,deployment,ingress}.yaml
sed -i -e "s#__NAME__#$NAME#g" ./out/{service,deployment,ingress}.yaml
sed -i -e "s#__URL__#$URL#g" ./out/{service,deployment,ingress}.yaml
rm -rf ./out/*-e
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: __NAME__
namespace: review
labels:
application: __NAME__
spec:
replicas: 1
selector:
matchLabels:
application: __NAME__
template:
metadata:
labels:
application: __NAME__
spec:
imagePullSecrets:
- name: regsecret
containers:
- name: __NAME__
image: __IMAGE__
imagePullPolicy: Always
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: __NAME__
namespace: websites
annotations:
kubernetes.io/ingress.class: "public"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- secretName: lets-encrypt
hosts:
- __URL__
rules:
- host: "__URL__"
http:
paths:
- path: /
backend:
serviceName: __NAME__
servicePort: 80
apiVersion: v1
kind: Service
metadata:
name: __NAME__
namespace: review
labels:
application: __NAME__
spec:
type: NodePort
selector:
application: __NAME__
ports:
- port: 80
targetPort: 80
......@@ -95,19 +95,16 @@ cd "$CWD"
echo "Creating namespaces and saving SSL certs"
NAMESPACES=("websites" "monitoring" "ingress" "status-site" "kube-system" "gitlab")
NAMESPACES=("websites" "monitoring" "ingress" "status-site" "kube-system" "gitlab" "review")
for namespace in ${NAMESPACES[@]}
do
kubectl create namespace "$namespace" || true # some of them already exist
kubectl create --namespace="$namespace" secret tls lets-encrypt --key "$CERTDIRPATH"/certificate.key --cert "$CERTDIRPATH"/certificate.crt || true # some of them already exist
kubectl create --namespace="$namespace" c"$CERTDIRPATH"/certificate.key --cert "$CERTDIRPATH"/certificate.crt || true # some of them already exist
kubectl create --namespace="$namespace" secret generic basic-auth --from-file=$CERTDIRPATH/auth || true # some of them already exist
kubectl --namespace="$namespace" create secret docker-registry regsecret --docker-server=registry.dbogatov.org --docker-username=dbogatov --docker-password=$DOCKERPASS --docker-email=dmytro@dbogatov.org
done
echo "Deploying the registry secret"
kubectl --namespace=websites create secret docker-registry regsecret --docker-server=registry.dbogatov.org --docker-username=dbogatov --docker-password=$DOCKERPASS --docker-email=dmytro@dbogatov.org
# Save SSL certs
kubectl create secret generic kubernetes-dashboard-certs --from-file=$CERTDIRPATH -n kube-system
......
......@@ -12,4 +12,4 @@ source ./.secret.sh
curl -s -X PUT -d "$CERTBOT_VALIDATION" --user $EMAIL:$PASSWORD https://box.dbogatov.org/admin/dns/custom/_acme-challenge.$CERTBOT_DOMAIN/TXT
sleep 5
sleep 10
......@@ -9,6 +9,7 @@ MAIN=("dbogatov.org" "dmytro.app" "bogatov.app")
DOMAINS["__MAIN__"]=true
DOMAINS["cluster.__MAIN__"]=false
DOMAINS["pages.__MAIN__"]=false
DOMAINS["review.__MAIN__"]=false
DOMAINS["netwatch.app"]=true
DOMAINS["orlova.app"]=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment