diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 504251f..32c824b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,10 @@ stages: - test - publish - - check_published + - deploy + +variables: + KUBENS: senpy docker: stage: publish @@ -63,9 +66,29 @@ check_pypi: tags: - docker image: python:3.7 - stage: check_published + stage: deploy script: - pip install senpy==$CI_COMMIT_TAG # Allow PYPI to update its index before we try to install when: delayed start_in: 10 minutes + +deploy: + only: + refs: + - master + tags: + - docker + image: alpine/k8s:1.22.6 + stage: deploy + environment: production + variables: + KUBECONFIG_FILE: "/kubeconfig" + IMAGEWTAG: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" + KUBEAPP: "senpy" + script: + - cat ${KUBECONFIG} > $KUBECONFIG_FILE + - kubectl version + - cd k8s/ + - cat *.yaml *.tmpl 2>/dev/null | envsubst | kubectl --kubeconfig $KUBECONFIG_FILE apply --namespace ${KUBENS:-default} -f - + - kubectl --kubeconfig $KUBECONFIG_FILE get all,ing -l app=${KUBEAPP} --namespace=${KUBENS:-default} diff --git a/k8s/senpy-deployment.yaml b/k8s/senpy-deployment.yaml index 4556734..73d811c 100644 --- a/k8s/senpy-deployment.yaml +++ b/k8s/senpy-deployment.yaml @@ -9,7 +9,7 @@ spec: metadata: labels: role: senpy-latest - app: test + app: senpy spec: containers: - name: senpy-latest diff --git a/k8s/senpy-ingress.yaml b/k8s/senpy-ingress.yaml index 656ddb8..d5ac4a2 100644 --- a/k8s/senpy-ingress.yaml +++ b/k8s/senpy-ingress.yaml @@ -1,21 +1,19 @@ --- -apiVersion: extensions/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: senpy-ingress + labels: + app: senpy spec: rules: - host: latest.senpy.gsi.upm.es http: paths: - path: / + pathType: Prefix backend: - serviceName: senpy-latest - servicePort: 5000 - - host: latest.senpy.gsi.upm.es - http: - paths: - - path: / - backend: - serviceName: senpy-latest - servicePort: 5000 + service: + name: senpy-latest + port: + number: 5000 diff --git a/k8s/senpy-svc.yaml b/k8s/senpy-svc.yaml index 5d5c21e..36aea4c 100644 --- a/k8s/senpy-svc.yaml +++ b/k8s/senpy-svc.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: Service metadata: name: senpy-latest + labels: + app: senpy spec: type: ClusterIP ports: