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

Template update

parent e5e6f755
Branches
Tags
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:
DEV_ENVIROMENT: "development" #change-this-value : The name of environment created in GitLab project - see https://docs.gitlab.com/ee/ci/environments/
APP_NAME: ps-k8s-app #change-this-value : Your app name - value used in file k8s-manifests/k8s.templ.yml
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
DEFAULT_DOMAIN: ${DEFAULT_DOMAIN} #This value is prowived by administrator and configured in "Project Settings"
DEV_ENVIROMENT: "development" #change-this-value : The name of environment created in GitLab project - see https://docs.gitlab.com/ee/ci/environments/
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:
- build
- deploy
- post_deployment
- 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
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
- echo $CI_PROJECT_DIR/Dockerfile
- echo $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- 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:
- ${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
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
......@@ -50,7 +44,7 @@ deploy_dev: #This is an example job name. Please change it change acco
- deployment.yml
environment: #You can remove 'environment' section if no environment is used
name: ${DEV_ENVIROMENT}
url: "http://${APP_URL}"
url: "https://${APP_URL}"
on_stop: stop_environment
#rules:
# - when: never
......@@ -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
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}
script:
- 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
rules:
# - when: never
- 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
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
- ${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
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
image: ${KUBECTL_IMAGE}
script:
......@@ -99,7 +94,7 @@ destroy_environment: #This is an example job name. Please change it change acco
- kubectl delete deployments --all
- kubectl delete persistentvolumeclaims --all
- kubectl delete persistentvolume --all
- kubectl delete mappings.getambassador.io --all
- kubectl delete ingress --all
- kubectl delete services --all
environment: #You can remove 'environment' section if no environment is used
name: ${DEV_ENVIROMENT}
......@@ -110,10 +105,46 @@ destroy_environment: #This is an example job name. Please change it change acco
tags:
- ${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
#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
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}
script:
- 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
- when: manual
tags:
- ${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:
---
#REQUIRED - but only for containers that required public access to it. One Mapping is for one public URL
apiVersion: getambassador.io/v3alpha1
kind: Mapping
apiVersion: networking.k8s.io/v1
kind: Ingress
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:
hostname: ${APP_URL}
prefix: /
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
ingressClassName: nginx
rules:
- 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
......@@ -38,15 +47,13 @@ apiVersion: v1
kind: PersistentVolumeClaim
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
namespace: ${KUBE_NAMESPACE} #Do not change this!
# namespace: ps-test
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Mi
storage: 1Gi
---
#REQUIRED
apiVersion: apps/v1
......@@ -60,15 +67,18 @@ spec:
matchLabels:
appsvc: nginx
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
appsvc: nginx
spec:
## serviceAccountName: ps-test
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
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}'
imagePullPolicy: IfNotPresent
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: Always
volumeMounts:
- name: nginx-vol
mountPath: /usr/share/nginx/html
......@@ -87,6 +97,6 @@ spec:
- name: nginx-vol
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
imagePullSecrets:
- name: gitlab-registry-secret #Do not change this!
#imagePullSecrets:
#- name: gitlab-registry-secret #Do not change this!
\ No newline at end of file
apiVersion: v1
kind: Config
clusters:
- cluster:
certificate-authority-data: ${KUBECONF_CERT_AUTHORITY_DATA}
certificate-authority-data: "${KUBECONF_CERT_AUTHORITY_DATA}"
server: ${KUBECONF_SERVER}
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: {}
name: cluster-local
users:
- name: ${KUBECONF_USER}
- name: kube-user
user:
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