Skip to content
Snippets Groups Projects
Commit 31546990 authored by Paweł Sierota's avatar Paweł Sierota
Browse files

Template update

parent e5e6f755
No related branches found
No related tags found
No related merge requests found
Pipeline #85034 failed
#
# Example CI/CD pipeline (file .gitlab-ci.yaml) for build and manage simple one-container application
# Please modify code below according corresponding comments and copy it to your custom .gitlab-ci.yaml file
#
# Tag description:
# REQUIRED - job required for build and deploy containers
# OPTIONAL - job useful for manage environment and K8s resources
# EXAMPLE - exaple job showing how to perform some task - after modification from corresponding comments
# change-this-value - be sure to set the values marked with this tag
variables: variables:
DEV_ENVIROMENT: "development" #change-this-value : The name of environment created in GitLab project - see https://docs.gitlab.com/ee/ci/environments/ DEFAULT_DOMAIN: ${DEFAULT_DOMAIN} #This value is prowived by administrator and configured in "Project Settings"
APP_NAME: ps-k8s-app #change-this-value : Your app name - value used in file k8s-manifests/k8s.templ.yml DEV_ENVIROMENT: "development" #change-this-value : The name of environment created in GitLab project - see https://docs.gitlab.com/ee/ci/environments/
APP_URL: "pawel.test.software.geant.org" #change-this-value : The URL for your application. This include your application name you provide in request ticket. Full URL will be provided by administrator APP_NAME: my-app-naem #change-this-value : Your app name - value used in file k8s-manifests/k8s.templ.yml
APP_URL: "${APP_NAME}.${DEFAULT_DOMAIN}" #change-this-value : The URL for your application.
stages: stages:
- build - build
- deploy - deploy
- post_deployment
- mgmt - mgmt
- post_deploy - cluster_tools
#REQUIRED Job for building your image based on Dockerfile in main repo directory. Please do not change code below except parameters/values mentioned in corresponding comments #REQUIRED Job for building your image based on Dockerfile in main repo directory. Please do not change code below except parameters/values mentioned in corresponding comments
build_app: #This is an example job name. Please change it change according to your needs build_app: #This is an example job name. Please change it change according to your needs
...@@ -31,10 +24,11 @@ build_app: #This is an example job name. Please change it change accord ...@@ -31,10 +24,11 @@ build_app: #This is an example job name. Please change it change accord
- echo $CI_PROJECT_DIR/Dockerfile - echo $CI_PROJECT_DIR/Dockerfile
- echo $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - echo $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA #You can change --dockerfile and --destination CI_COMMIT_SHA for custom image tag - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} #You can change --dockerfile and --destination CI_COMMIT_SHA for custom image tag
tags: tags:
- ${RUNNER_NAME} - ${RUNNER_NAME}
#REQUIRED Job for deploy your app to kK8s cluster based on k8s-manifests/k8s.templ.yml manifests. Please do not change code below except parameters/values mentioned in corresponding comments #REQUIRED Job for deploy your app to kK8s cluster based on k8s-manifests/k8s.templ.yml manifests. Please do not change code below except parameters/values mentioned in corresponding comments
deploy_dev: #This is an example job name. Please change it change according to your needs deploy_dev: #This is an example job name. Please change it change according to your needs
stage: deploy #This is an example stage name. Please change it change according to your needs stage: deploy #This is an example stage name. Please change it change according to your needs
...@@ -50,7 +44,7 @@ deploy_dev: #This is an example job name. Please change it change acco ...@@ -50,7 +44,7 @@ deploy_dev: #This is an example job name. Please change it change acco
- deployment.yml - deployment.yml
environment: #You can remove 'environment' section if no environment is used environment: #You can remove 'environment' section if no environment is used
name: ${DEV_ENVIROMENT} name: ${DEV_ENVIROMENT}
url: "http://${APP_URL}" url: "https://${APP_URL}"
on_stop: stop_environment on_stop: stop_environment
#rules: #rules:
# - when: never # - when: never
...@@ -59,7 +53,7 @@ deploy_dev: #This is an example job name. Please change it change acco ...@@ -59,7 +53,7 @@ deploy_dev: #This is an example job name. Please change it change acco
#EXAMPLE job for operations inside running containers. Please do not change code below except parameters/values mentioned in corresponding comments #EXAMPLE job for operations inside running containers. Please do not change code below except parameters/values mentioned in corresponding comments
copy_static_cntent: #This is an example job name. Please change it change according to your needs copy_static_cntent: #This is an example job name. Please change it change according to your needs
stage: post_deploy #This is an example stage name. Please change it change according to your needs stage: post_deployment #This is an example stage name. Please change it change according to your needs
image: ${KUBECTL_IMAGE} image: ${KUBECTL_IMAGE}
script: script:
- envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml - envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml
...@@ -73,6 +67,7 @@ copy_static_cntent: #This is an example job name. Please change it change ac ...@@ -73,6 +67,7 @@ copy_static_cntent: #This is an example job name. Please change it change ac
rules: rules:
# - when: never # - when: never
- when: manual - when: manual
- when: always
#OPTIONAL job for delete deployment - it deletes only container (deployment and pods) not services, persistent volumes. etc. Please do not change code below except parameters/values mentioned in corresponding comments #OPTIONAL job for delete deployment - it deletes only container (deployment and pods) not services, persistent volumes. etc. Please do not change code below except parameters/values mentioned in corresponding comments
stop_environment: #This is an example job name. Please change it change according to your needs stop_environment: #This is an example job name. Please change it change according to your needs
...@@ -91,7 +86,7 @@ stop_environment: #This is an example job name. Please change it change acco ...@@ -91,7 +86,7 @@ stop_environment: #This is an example job name. Please change it change acco
- ${RUNNER_NAME} - ${RUNNER_NAME}
#OPTIONAL job for destroy whole environment - it deletes all Kubernetes resouces. Please do not change code below except parameters/values mentioned in corresponding comments #OPTIONAL job for destroy whole environment - it deletes all Kubernetes resouces. Please do not change code below except parameters/values mentioned in corresponding comments
destroy_environment: #This is an example job name. Please change it change according to your needs cleanup_environment: #This is an example job name. Please change it change according to your needs
stage: mgmt #This is an example stage name. Please change it change according to your needs stage: mgmt #This is an example stage name. Please change it change according to your needs
image: ${KUBECTL_IMAGE} image: ${KUBECTL_IMAGE}
script: script:
...@@ -99,7 +94,7 @@ destroy_environment: #This is an example job name. Please change it change acco ...@@ -99,7 +94,7 @@ destroy_environment: #This is an example job name. Please change it change acco
- kubectl delete deployments --all - kubectl delete deployments --all
- kubectl delete persistentvolumeclaims --all - kubectl delete persistentvolumeclaims --all
- kubectl delete persistentvolume --all - kubectl delete persistentvolume --all
- kubectl delete mappings.getambassador.io --all - kubectl delete ingress --all
- kubectl delete services --all - kubectl delete services --all
environment: #You can remove 'environment' section if no environment is used environment: #You can remove 'environment' section if no environment is used
name: ${DEV_ENVIROMENT} name: ${DEV_ENVIROMENT}
...@@ -110,10 +105,46 @@ destroy_environment: #This is an example job name. Please change it change acco ...@@ -110,10 +105,46 @@ destroy_environment: #This is an example job name. Please change it change acco
tags: tags:
- ${RUNNER_NAME} - ${RUNNER_NAME}
download_logs:
stage: mgmt
image: ${KUBECTL_IMAGE}
script:
- envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml
- APP_POD=`kubectl get pod | awk -v patt=${APP_NAME} '$1 ~ patt {print $1}'`
- mkdir -p ./download/logs
- echo $APP_POD
- kubectl cp $APP_POD:/var/log ./download/logs
artifacts:
expire_in: 5 mins
name: nginx-logs
paths:
- download/logs
allow_failure: true
rules:
- when: manual
tags:
- ${RUNNER_NAME}
##### claster tools
kubectl:
stage: cluster_tools
image: ${KUBECTL_IMAGE}
script:
- envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml
- echo "=== KUBECTL OUTPUT ============================================================"
- echo "kubectl ${cmd}"
- kubectl ${cmd}
- echo "==============================================================================="
allow_failure: true
rules:
- when: manual
tags:
- ${RUNNER_NAME}
#EXAMPLE job for manage your K8s resources - here for obtaining pods status. Please do not change code below except parameters/values mentioned in corresponding comments #EXAMPLE job for manage your K8s resources - here for obtaining pods status. Please do not change code below except parameters/values mentioned in corresponding comments
#You can use this job to perform any 'kubectl' tasks #You can use this job to perform any 'kubectl' tasks
get_pods_info: #This is an example job name. Please change it change according to your needs get_pods_info: #This is an example job name. Please change it change according to your needs
stage: mgmt #This is an example stage name. Please change it change according to your needs stage: cluster_tools #This is an example stage name. Please change it change according to your needs
image: ${KUBECTL_IMAGE} image: ${KUBECTL_IMAGE}
script: script:
- envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml - envsubst < k8s-manifests/kubeconfig.templ.yml > kubeconfig.yml
...@@ -123,4 +154,3 @@ get_pods_info: #This is an example job name. Please change it change accordin ...@@ -123,4 +154,3 @@ get_pods_info: #This is an example job name. Please change it change accordin
- when: manual - when: manual
tags: tags:
- ${RUNNER_NAME} - ${RUNNER_NAME}
FROM nginx
COPY ./static-html/index.html /usr/share/nginx/html/
COPY ./static-html/custom_404.html /usr/share/nginx/html/
\ No newline at end of file
...@@ -23,14 +23,23 @@ spec: ...@@ -23,14 +23,23 @@ spec:
--- ---
#REQUIRED - but only for containers that required public access to it. One Mapping is for one public URL #REQUIRED - but only for containers that required public access to it. One Mapping is for one public URL
apiVersion: getambassador.io/v3alpha1 apiVersion: networking.k8s.io/v1
kind: Mapping kind: Ingress
metadata: metadata:
name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Mapping - in such a case please append appropriare suffix, for example ${APP_NAME}-nginx name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Service - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container
spec: spec:
hostname: ${APP_URL} ingressClassName: nginx
prefix: / rules:
service: ${APP_NAME}:8080 #Do not change value '${APP_NAME} ' except you have more then one Mapping - in such a case please append appropriare suffix, for example ${APP_NAME}-nginx - host: ${APP_URL}
http:
paths:
- backend:
service:
name: ${APP_NAME}
port:
number: 8080
path: /
pathType: Prefix
--- ---
#OPTIONAL - only when your application required persistent volume. This refers to 'volumes' in corresponding Deployment manifest. Please comment/remove whole this section if your application does not reqiure persisteng volumes #OPTIONAL - only when your application required persistent volume. This refers to 'volumes' in corresponding Deployment manifest. Please comment/remove whole this section if your application does not reqiure persisteng volumes
...@@ -38,15 +47,13 @@ apiVersion: v1 ...@@ -38,15 +47,13 @@ apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one PersistentVolumeClaim - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one PersistentVolumeClaim - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container
namespace: ${KUBE_NAMESPACE} #Do not change this! # namespace: ps-test
spec: spec:
storageClassName: nfs-client
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:
requests: requests:
storage: 20Mi storage: 1Gi
--- ---
#REQUIRED #REQUIRED
apiVersion: apps/v1 apiVersion: apps/v1
...@@ -60,15 +67,18 @@ spec: ...@@ -60,15 +67,18 @@ spec:
matchLabels: matchLabels:
appsvc: nginx appsvc: nginx
replicas: 1 replicas: 1
strategy:
type: Recreate
template: template:
metadata: metadata:
labels: labels:
appsvc: nginx appsvc: nginx
spec: spec:
## serviceAccountName: ps-test
containers: containers:
- name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Deployment - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container - name: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Deployment - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} #Do not change value '${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}' except you want to use custom image teag - in such a case please change '${CI_COMMIT_SHA}' image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} #Do not change value '${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}' except you want to use custom image teag - in such a case please change '${CI_COMMIT_SHA}'
imagePullPolicy: IfNotPresent imagePullPolicy: Always
volumeMounts: volumeMounts:
- name: nginx-vol - name: nginx-vol
mountPath: /usr/share/nginx/html mountPath: /usr/share/nginx/html
...@@ -87,6 +97,6 @@ spec: ...@@ -87,6 +97,6 @@ spec:
- name: nginx-vol - name: nginx-vol
persistentVolumeClaim: persistentVolumeClaim:
claimName: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Deployment - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container claimName: ${APP_NAME} #Do not change value '${APP_NAME} ' except you have more then one Deployment - in such a case please append appropriate suffix, for example ${APP_NAME}-db_container
imagePullSecrets: #imagePullSecrets:
- name: gitlab-registry-secret #Do not change this! #- name: gitlab-registry-secret #Do not change this!
\ No newline at end of file
apiVersion: v1 apiVersion: v1
kind: Config
clusters: clusters:
- cluster: - cluster:
certificate-authority-data: ${KUBECONF_CERT_AUTHORITY_DATA} certificate-authority-data: "${KUBECONF_CERT_AUTHORITY_DATA}"
server: ${KUBECONF_SERVER} server: ${KUBECONF_SERVER}
name: cluster.local name: cluster-local
contexts:
- context:
cluster: cluster.local
user: ${KUBECONF_USER}
name: ${KUBECONF_USER}@cluster.local
current-context: ${KUBECONF_USER}@cluster.local
kind: Config
preferences: {}
users: users:
- name: ${KUBECONF_USER} - name: kube-user
user: user:
token: ${KUBECONF_TOKEN} token: ${KUBECONF_TOKEN}
contexts:
- context:
cluster: cluster-local
user: kube-user
namespace: ${KUBE_NAMESPACE}
name: default
current-context: default
h1 style='color:red'>Error 404: Not found :-(</h1>
<p>I have no idea where that file is, sorry. Are you sure you typed in the correct URL?</p>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1> Some awesome pgae</h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>GN 2023</title>
</head>
<body>
<h1> GÉANT Project Symposium 2023</h1>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment