platform
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
-
Cloning
Clone this repository, including the submodules by running:
$ git clone --recurse-submodules https://github.com/ArielLahiany/platform.git -
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 -
Tokens Generating
Generate access tokens by going to your DockerHub account, and following the instructions.
-
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_TOKENDOCKERHUB_USERNAME -
Configuration
The platform is using a couple of variables. For security and production reasons, please change them to your own.
-
Mandatory
- SECRET_KEY: Uses for creation of hashes. (Inside the secret.yaml file of the Saleor Core manifests).
- API_URL: Defines URI of a running instance of the Saleor GraphQL API. (Inside the Dockerfiles of the Storefront, and Dashboard applications).
- DASHBOARD_URL: Default Saleor Dashboard URL. (Inside the config.yaml file of the Saleor Core manifests)
- STOREFRONT_URL: Default Saleor Storefront URL. (Inside the config.yaml file of the Saleor Core manifests)
- 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).
-
Optional
- api_url: An webhook for Slack notifications. (Inside the config.yaml file of the Prometheus Alertmanager manifests).
-
Mandatory
-
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.yamlfile, 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:
Optional: if you would like to get push notifications by a Slack webhook, add another access token for your channel:<DockerHub_Username>/<Repository_Name>:<Tag>SLACK_WEBHOOKit 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.
-
Applying
The project has two main entrypoints: Kustomization file, and Ansible playbooks. You may choose each one.
-
Kustomization:
In the root directory, run the following command in a terminal:
$ kubectl apply -k ./ -
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.
-
Kustomization:
In the root directory, run the following command in a terminal:
-
Database Populating
If you like to populate your database with pre-created data, and an example superuser:
- Exec: exec into your Django application pods.
- Run: the following command:
$ python manage.py populatedb --createsuperuserThe 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: