platform icon indicating copy to clipboard operation
platform copied to clipboard

All Saleor services started from a single repository with Ansible, Terraform, and Kubernetes.

Saleor Kubernetes Platform

Customer-centric e-commerce on a modern stack.
Headless, GraphQl first e-commerce platform delivering ultra-fast, dynamic, personalized shopping experiences.

Table of Contents

  • Stack
  • Requirements
  • Installation
  • tasks
  • Inspiration

Stack

  • Django

    An high-level Python Web framework that encourages rapid development and clean, pragmatic design.

  • React

    A JavaScript library for building user interfaces, by Facebook.

  • GraphQL

    GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.

  • Docker

    An open source software platform to create, deploy and manage virtualized application containers on a common operating systems.

  • Kubernetes

    an open-source orchestration tool for automating deployment, scaling, and management of containerized applications.

  • Continuous Integration

    GitHub Actions pipelines for Continuous Integration by running pre-coded tests, building, and pushing into a private DockerHub repository.

  • Continuous Deployment

    GitHub Actions pipelines for Continuous Deployment by automatic deployment into a Google Kubernetes Engine hosted cluster.

  • Monitoring

    Visualize the performance of the Kubernetes Cluster infrastructures. By Prometheus monitoring system, and time series database integration with Grafana dashboards monitoring.

Requirements

  • Mandatory
    • ARM64 Machine: Some of the images used in that project are made for ARM64 architecture only.
    • Docker Engine: Installation of the latest Docker Engine version.
    • Kubernetes Cluster: It can be a remote or a local cluster, running by microk8s, minikube, desktop-docker, or any eqvivalent.
  • Optional
    • Ansible: A popular IT automation engine that automates tasks.
    • Terraform: An open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.

Installation

  1. Cloning

    Clone this repository, including the submodules by running:

    $ git clone --recurse-submodules https://github.com/ArielLahiany/platform.git
    
  2. Code Management.

    Create three GitHub repositories: Saleor (Core), Dashboard and Storefront. Enter the relevant submodules directories, and then preform initial Commit and Push it by running:

    $ git commit -m "Initial Commit"
    
    $ git push origin master
    
  3. Tokens Generating

    Generate access tokens by going to your DockerHub account, and following the instructions.

  4. GitHub Secrets

    The pipelines uses the access tokens for authentication, and in order to push the images to DockerHub repositories. We recommend to use them by creating new secrets on your GitHub repositories. By default the variables are called:

    DOCKERHUB_TOKEN
    
    DOCKERHUB_USERNAME
    
  5. Configuration

    The platform is using a couple of variables. For security and production reasons, please change them to your own.

    1. Mandatory
      1. SECRET_KEY: Uses for creation of hashes. (Inside the secret.yaml file of the Saleor Core manifests).
      2. API_URL: Defines URI of a running instance of the Saleor GraphQL API. (Inside the Dockerfiles of the Storefront, and Dashboard applications).
      3. DASHBOARD_URL: Default Saleor Dashboard URL. (Inside the config.yaml file of the Saleor Core manifests)
      4. STOREFRONT_URL: Default Saleor Storefront URL. (Inside the config.yaml file of the Saleor Core manifests)
      5. Image: Please change the image section of the deployment files to your own DockerHub repositories. (Inside all the deployment files of the Saleor Core, Storefront and Dashboard applications).
    2. Optional
      1. api_url: An webhook for Slack notifications. (Inside the config.yaml file of the Prometheus Alertmanager manifests).
  6. Building and Pushing

    Go into the

    .github/workflows/
    

    directory in your repositories. You will find there the CI pipelines that are responsible for testing, building and pushing the images to your DockerHub repositories. Enter the

    docker-publish.yaml
    

    file, and look up for the Build and Push section. You'll find there the tag flag of the image. Please change it into your own DockerHub username:

    <DockerHub_Username>/<Repository_Name>:<Tag>
    
    Optional: if you would like to get push notifications by a Slack webhook, add another access token for your channel:
    SLACK_WEBHOOK
    

    it is recommended, but not mandatory. In case you would not like to get those notifications, comment or remove the Notification section of the pipeline file.

  7. Applying

    The project has two main entrypoints: Kustomization file, and Ansible playbooks. You may choose each one.

    1. Kustomization: In the root directory, run the following command in a terminal:
      $ kubectl apply -k ./
      
    2. Ansible Playbooks: Change directory to
      /resoucres/playbooks/
      

      and run the following command:

      $ ansible-playbooks platform.yaml
      

    Normal Django projects need to run migrations into the new database. For automation goals, this project include init-containers which does that, pre-launching the pods.

  8. Database Populating

    If you like to populate your database with pre-created data, and an example superuser:

    1. Exec: exec into your Django application pods.
    2. Run: the following command:
    3. $ python manage.py populatedb --createsuperuser
      

    The default credentials are:

    [email protected]
    
    admin
    

Tasks

  • Terraform

    Fix login issues with Google Kubernetes Engine, clone the entire project and deploy it on the remote cluster automatically.

  • GitHub Actions

    Finish CD pipelines for deployments, by integration with the GKE cluster.

  • Jenkins

    Finish Jenkins files for building and deployments by agents which running by on-demand Kubernetes pods.

  • High Availability

    Move Redis, Postgres and other services to High Availability configuration.

Inspiration

During the development of that project, I've taken inspiration and knowledge from other repositories, here on GitHub. The main of them are listed down here:

  • Saleor

    A modular, high performance, headless e-commerce platform built with Python, GraphQL, Django, and React.

  • Gimbal

    An ingress load balancing platform capable of routing traffic to multiple Kubernetes and OpenStack clusters. Built by Heptio in partnership with Actapio.