Giter Club home page Giter Club logo

openstack-magnum-gitlab's Introduction

OpenStack Magnum with deplyment of GitLab CI/CD

Deployment of a Kubernetes Cluster and GitLab CI/CD

Prerequisites:
- Docker
- Docker Compose
- Python 3
 - python-magnumclient
 - python-openstackclient

You also need basic understanding of OpenStack Heat Templates and Docker.

Basic setup instructions

Install dependencies

git clone https://github.com/DiFronzo/OpenStack-Magnum-GitLab.git
cd OpenStack-Magnum-GitLab
pip3 install -r requirements.txt

Installation of Docker is found her and Docker Compose is found her for Linux.

Run the cluster

First you will need to log in to your OpenStack infrastructure and download the openrc file.

source openrc.sh #source your own openrc from OpenStack

Next edit iac_cluster_env.yaml and enter name of your keypair and external_network. You don't have a keypair? Look at this guide. You will also need to edit parameters in iac_cluster.yaml for flavor, node_count, and etc.

Once you have finished the steps above, you can now deploy the stack. Change <name-of-stack> with a name of your choosing.

openstack stack create <name-of-stack> -t iac_cluster.yaml -e iac_cluster_env.yaml

Now wait until the cluster has the status "CREATE_COMPLETE"

openstack coe cluster list

The next step is to configure the newly created Kubernetes cluster, this needs Docker and Docker Compose to run locally.

vim .env

The file should look something similar to the following with URL and TOKEN from your prefered gitlab and follow "project-specific runner". Add the UUID or name of the cluster in "CLUSTER=" (workes best with UUID (use openstack coe cluster list to find this).

# .env.compose
URL=https://gitlab.com/
TOKEN=
CLUSTER=

Then add env. variables for OpenStack access. This include you password in clear text! Do not upload this file anywhere!

(env | grep OS_) >>.env

Last step is to build and run docker-composer to establish a connection between Kubernetes and GitLab.

docker-compose build
docker-compose up

Usage (Kubernetes)

When the cluster is created you can do the following to connect.

mkdir -p ~/clusters/kubernetes-cluster
$(openstack coe cluster config <your-cluster> --dir ~/clusters/kubernetes-cluster)
kubectl get nodes

If lost connection:

export KUBECONFIG=~/clusters/kubernetes-cluster/config

Delete everything created for gitlab-runner

If you want to remove everything connected to gitlab-runner.

kubectl delete deployment,configmap,rolebinding,role,serviceaccount --all --namespace=gitlab-runner
kubectl delete namespace gitlab-runner

Setup everything created for gitlab-runner

To add the configuration again. You will have to first remove your token from gitlab-runner-k8s.yaml so, it look like this token =.

docker-compose build
docker-compose up

Scale nodes

To change the number of nodes in your cluster, you can do the following:

openstack coe cluster update <your-cluster> replace node_count=<N>

Scale GitLab runners

To change the number of pods in your cluster, you can change the following line in the YAML template (gitlab-runner-k8s.yaml):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-runner
  namespace: gitlab-runner
spec:
  replicas: X

To change the amount of requested or limit the amount of the gitlab-runners, you can change or add the following line(s) in the YAML template. Further information on Kubernetes.io.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-runner
  namespace: gitlab-runner
...
...
          image: gitlab/gitlab-runner:latest
          imagePullPolicy: Always
          name: gitlab-runner
          resources:
            requests:
              cpu: "X"
              memory: "X"
            limits:
              cpu: "X"
              memory: "X"

About the project

What is this repo actually doing ?

This repo is for easy deplyment of a Kubernetes Cluster and for adding a connection to a GitLab repo CI/CD.

Please see the road map section of the README.md to see upcoming functionality and releases of the module.

Limitations

There is a bug in OpenStack Magnum that does not allow activating "Docker Registry" in the Heat Template.

Road Map (For this repo)

Here is the functionality that is on the road map for this repo

  • Overwrite the token in gitlab-runner-k8s.yaml when running Docker Compose.
  • Support for GitHub CI/CD.

openstack-magnum-gitlab's People

Contributors

difronzo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.