diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..aa6f7c82bee3af67591aa96d78503f4e8a49caff --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,41 @@ +stages: + - build + - deploy + +variables: + DOCKER_IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} + DOCKER_TLS_CERTDIR: "" + +.build: + stage: build + image: docker + services: + - docker:dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker build -t ${DOCKER_IMAGE} --no-cache . + - docker push ${DOCKER_IMAGE} + - docker rmi ${DOCKER_IMAGE} + - docker logout $CI_REGISTRY + +.deploy: + stage: deploy + image: dockerhub.ebi.ac.uk/kamal/deploy-tools:0.1 + + script: + - sed -i "s#<DOCKER_IMAGE>#${DOCKER_IMAGE}#g" k8s/deployment.yaml + - kubectl apply -f k8s/deployment.yaml + - kubectl apply -f k8s/service-node.yaml + +build: + extends: .build + only: + - master + +deploy: + extends: .deploy + environment: + name : ehk-sbox + only: + - master diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0811c6ed77ee4c7256e9dd5b7d1ffc408785e701 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: ensembl-docs-prototype-deployment +spec: + replicas: 1 + template: + metadata: + labels: + app: ensembl-docs-prototype + spec: + imagePullSecrets: + - name: ensembl-docs-prototype-secret + containers: + - name: ensembl-docs-prototype + image: <DOCKER_IMAGE> + command: [ "npm", "run", "start-server" ] + ports: + - containerPort: 3000 + imagePullPolicy: Always diff --git a/k8s/references.md b/k8s/references.md new file mode 100644 index 0000000000000000000000000000000000000000..e1ea07d59171a02eb7b76360a02e71e0d3f43104 --- /dev/null +++ b/k8s/references.md @@ -0,0 +1,26 @@ +Our docs: +- [Deploying new site on WP-k8s Cluster](https://www.ebi.ac.uk/seqdb/confluence/display/ENSWEB/Deploying+new+site+on+WP-k8s+Cluster) + +Uniprot docs: +- [Using Gitlab CI, Docker, and Kubernetes to host static content](https://www.ebi.ac.uk/seqdb/confluence/display/UniProt/Using+GitLab+CI%2C+Docker+and+Kuberentes+To+Host+Static+Content) + +Summary of steps: +- Create secret for pulling images from the docker registry associated with your gitlab repository: + +``` +kubehk-sbox -n ensembl-experiments create secret docker-registry <your secret name> --docker-server=dockerhub.ebi.ac.uk --docker-username=<your username> --docker-password=<your gitlab access token> --docker-email=<your email> +```` + +- create deployment manifest (deployment.yaml) +- create service manifest with type nodeport to get access outside cluster (service.yaml) +- add `.gitlab-ci.yml`, in which, during the deployment step, both manifests will be applied to kubernetes: + - apply deployment manifest (kubectl --kubecoonfig=<kubeconfig_file> apply -f deployment.yaml) + - apply service manifest (kubectl --kubecoonfig=<kubeconfig_file> apply -f service.yaml) +- identify the port of the service (from kubectl get svc) and identify host (from kube config file) + +Note: +- our experimental cluster: kubehk-sbox +- use ensembl-experiments namespace for experiments + +Questions: +- why do some of our gitlab-ci yaml files do have a line applying diff --git a/k8s/service-node.yaml b/k8s/service-node.yaml new file mode 100644 index 0000000000000000000000000000000000000000..52f5bcb44f802c5a0113c037c85efdeebab087a5 --- /dev/null +++ b/k8s/service-node.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: ensembl-docs-prototype-svc + labels: + app: ensembl-docs-prototype-svc +spec: + selector: + app: ensembl-docs-prototype + type: NodePort + ports: + - port: 8000 + protocol: TCP + targetPort: 3000