Skip to content

5. CI/CD and Helm installation of PrestaShop

Original Author: Sara Jokela
Last updated by Jesse Anttila
Last checked by Jesse Anttila
Lastmod: 7.10.2025
Status: In progress

Notes#

As of 7.10.2025 this PrestaShop installation conflicts with the simple service setup of the previous guide. We believe this is because ingress doesn't "listen to" the correct service. One way to get past this problem is to first remove both MicroK8s and kubectl, reinstall them and do the setup all over again, and then also redo agent and runner setups. This has been tested and verified, but is by no means an ideal way around this issue. We're currently working on a proper solution.

Introduction#

Introduction here

Prerequisites#

  • Forked repository from https://gitlab.labranet.jamk.fi/presta-shop-development-release-x/presta-shop-deployment/presta-shop-helm-x (remember to remove the fork relationship)
  • GitLab agent and runner deployed on your cPouta machine

Setting up GitLab CI/CD of MicroK8S#

For this part, you have to familiarize yourself with the Variables-part from the guide for deploying PrestaShop with Helm. They are used in the .gitlab-ci.yml file.

  1. Create a .gitlab-ci.yml file in your projects root. Contents of this file are discussed later.

  2. Select which variables you want to set yourself. Note, that you have to at least set the psDomain! This is used to deploy PrestaShop as http. Check your floating IP address for that.

  3. From the left side panel, choose Settings -> CI/CD -> Variables. Select Add variable. Give your variable a name, select visibility level, add the desired value and finally click Add variable.

    Note: You can set variables with different security levels. For example, passwords should be set with "Masked and hidden" visibility level.

    Adding variables

    In this example, variables ADMIN_PW and IP_ADD are added. IP_ADD is a public variable, and it has the floating IP of the virtual machine as a value. ADMIN_PW is masked and hidden, and it's value is a new password for admin user.

    Variables in GitLab

  4. Next, you will have to create two python files to the root of the project. These files are used to create a package from PrestaShop Helm chart, and to push it to GitLabs package registry. The package is then used to build and deploy PrestaShop.

    First, create file called chart-name.py. Add following lines in it:

    import os
    
    f = open('prestashop/Chart.yaml','r')
    lines = f.readlines()
    for row in lines:
        if row.startswith("name"):
            chart=row
        if row.startswith("version"):
            version=row
    
    chart_name=chart.split(" ")
    ver=version.split(" ")
    print(chart_name[1].strip())
    f.close()
    

    Then, create file called package-name.py. Add following lines in it:

    import os
    
    f = open('prestashop/Chart.yaml','r')
    lines = f.readlines()
    for row in lines:
        if row.startswith("name"):
            chart=row
        if row.startswith("version"):
            version=row
    
    chart_name=chart.split(" ")
    ver=version.split(" ")
    package=chart_name[1].strip()+'-'+ver[1].strip()+'.tgz'
    print(package)
    f.close()
    
  5. Return to the .gitlab-ci.yml file. Add the following configuration and change values to match your own project.

    Remember to add your own project path and Kubernetes agent name to the KUBE_CONTEXT variable. It is probably something like YOURSTUDENTID/your-project-name:your-agent-name. Remember to write your student id with uppercase letters, since this variable is case sensitive!

    If you want to use https, you have to add your virtual machine's domain name as a variable. You also have to use --set prestashop.ingress.enabled=true to use HTTPS.

    # Stages for creating and pushing packages to registry, testing, building and deploying PrestaShop
    
    stages:
      - pre-build
      - helm-publish
      - test
      - build
      - deploy
    
    # Templates for different tests
    
    include:
      - template: Security/Dependency-Scanning.gitlab-ci.yml
      - template: Security/SAST.gitlab-ci.yml
      - template: Security/Secret-Detection.gitlab-ci.yml
      - template: Jobs/SAST.gitlab-ci.yml
    
    # Variables for testing and Kubernetes agent. Add your own project path and Kubernetes agent to KUBE_CONTEXT!
    
    variables:
      SAST_DEFAULT_ANALYZERS: eslint, semgrep
      DS_DEFAULT_ANALYZERS: retire.js/
      KUBE_CONTEXT: yourprojectpath/here:kubernetesagentnamehere
      SCAN_KUBERNETES_MANIFESTS: "true"
    
    sast:
      tags:
        - general
    
    dependency_scanning:
      stage: test
      tags:
        - general
    
    secret_detection:
      stage: test
      tags:
        - general
    
    # Create package from Helm chart
    Extract-Data:
      stage: pre-build
      image: python
      script:
        - echo PACKAGE_VERSION=$(python3 $CI_PROJECT_DIR/package-name.py) >> build.env
        - echo PACKAGE_NAME=$(python3 $CI_PROJECT_DIR/chart-name.py) >> build.env
    
      artifacts:
        reports:
          dotenv: build.env
    
      only:
        - main
      tags:
        - general
    
    # Push previously created packages to GitLabs package registry
    
    Publish-Helm-Package:
      stage: build
      image:
        name: alpine/helm:latest
        entrypoint: [""]
      script:
        - echo ${CI_PROJECT_ID}
        - echo $PACKAGE_NAME
        - echo $PACKAGE_VERSION
        - helm package $CI_PROJECT_DIR/$PACKAGE_NAME
        - 'curl --request POST --user gitlab-ci-token:$CI_REGISTRY_PASSWORD --form "chart=@${PACKAGE_VERSION}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
    
      only:
        - main
      tags:
        - general
    
    # Deploy PrestaShop with Helm using previously created packages from registry.
    # NOTE! You can add desired variables to helm upgrade with --set. Remember to check variables from the previously mentioned guide.
    # In this example, only two variables are set: floating IP with psDomain and a new admin password with adminPasswd.
    # Remember to define those values with "$".
    
    Deploy-Helm-Chart:
      stage: deploy
      image:
        name: dtzar/helm-kubectl
        entrypoint: [""]
      resource_group: deploy
      script:
        - kubectl config get-contexts
        - kubectl config use-context $KUBE_CONTEXT
        - helm repo add --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD prestashop "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable"
        - helm repo update
        - helm upgrade --install ${PACKAGE_NAME} prestashop/${PACKAGE_NAME} --set prestashop.env.psDomain=$IP_ADD --set prestashop.env.adminPasswd=$ADMIN_PW
        - kubectl get pods
        - kubectl get svc
      only:
        - main
      tags:
        - general
    

    Note that deployment might take some time. After a while, you should be able to access your PrestaShop at the IP address you defined earlier. This example will deploy PrestaShop as http!

Installing PrestaShop with Helm Chart and Internal Docker Images#

Once you have built your internal PrestaShop Docker images, you need to modify the Helm Chart in the GitLab repository presta-shop-helm-x.

  1. In GitLab, create a new Personal Access Token (PAT). Click on your profile picture -> Edit profile -> Access tokens -> Add new token. Give the token read_registry permissions.

  2. Create a Docker registry secret on the server (inside your cPouta VM)

    microk8s kubectl create secret docker-registry gitlab-registry-secret \
      --docker-server=gitlab.labranet.jamk.fi:4567 \
      --docker-username=<USERNAME> \
      --docker-password=<PERSONAL-ACCESS-TOKEN> \
      --docker-email=<EMAIL>
    

    This secret allows Kubernetes to pull your private Docker images from the GitLab registry.

  3. Modify the Helm Chart values

    Edit the file values.yaml in the presta-shop-helm-x repository.

    Below is a trimmed version showing only the parts you need to review or change.

    # --- PrestaShop settings ---
    prestashop:
      replicaCount: 1
    
      image:
        repository: <SERVICE-CONTAINER-IMAGE>    # <-- Replace with your built PrestaShop image
        pullPolicy: IfNotPresent
        tag: "latest"
    
      imagePullSecrets:
        - name: gitlab-registry-secret           # ADD SECRET
    
      ingress:
        enabled: true       # CHANGE — enable Ingress
        letsencrypt:
          isProd: true      # CHANGE — use production Let's Encrypt certificates
        className: "nginx"
        tls:
          - secretName: presta-shop-tls
    
      # You can change these here if needed.
      env:
        dbName: "prestashop"
      dbPasswd: "adminPrEsTa123"
        psDomain: "wimma-capstone.jamk.fi"        # <-- Set your actual domain
      psCountry: "FI"
      psLanguage: "en"
        adminMail: "testuser@mail.com"
        adminPasswd: "ReAlPaSsWoRd759***"
        psFolderAdmin: "admin228"
    
    # --- MySQL settings ---
    mysql:
      image:
        repository: <DATABASE-IMAGE>              # <-- Replace with your built PrestaShop Database image
        pullPolicy: IfNotPresent
        tag: "latest"
    
      imagePullSecrets:
        - name: gitlab-registry-secret            # ADD SECRET
    

    Note, use these addresses in the values.yaml file. The new images are in these repositories:

    Prestashop Image:

    gitlab.labranet.jamk.fi:4567/ref-product-line-v1-2025/ref-product-presta-shop-service-container-v1
    
    MySQL Image:
    gitlab.labranet.jamk.fi:4567/ref-product-line-v1-2025/ref-product-service-mysql-database-container-v1
    

  4. Ready to deploy

    Start the pipeline process.

    Note, deployment might take some time. After a while, you should be able to access your PrestaShop at the Domain you defined earlier as https.