Code Monkey home page Code Monkey logo

k3s-simple-deploy's Introduction

What is it?

GitHub Super-Linter

This repo contains code, which deploy k3s cluster (1 master and 2 worker nodes, but you can only deploy master node) and after that will deploy simple php application from kubernetes tutorials: https://kubernetes.io/docs/tutorials/stateless-application/guestbook/.

Given playbooks and roles will install all needed stuff to be able to run k3s cluster and php application, but we need some prerequisites before deploy.

Install prerequisites (venv, roles and collections)

Firstly, we need create python venv to run our deploy.

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt

Afterwards verify that ansible is installed by running ansible --version.

  • ansible-galaxy install -r requirements.yml
  • ansible-galaxy collection install -r requirements.yml

Secondly, we need some clean installation of Ubuntu Server 20.04 (code was tested only on this OS version).

Thirdly, we need to add entry with our deployment to system host file to further management. By default it is nginx_host: nginx.local and ip address of master node k3s_master: 192.168.2.100, so you will definetely change it depends on your setup.

Explanation of playbooks

Let's examine main.yaml file in root directory. It contains all playbooks which will deploy our setup.

"playbooks/users.yaml" — deploy user for deployment. It's common best practice to deploy such things by separate user. Edit environments/shared/users.yaml file to enter your user.

"playbooks/common.yaml" — update all packages and install needed python dependencies.

"playbooks/docker.yaml" — install latest docker engine to hosts.

"playbooks/k3s.yaml" — install k3s cluster to provided hosts. Before installation you can change master node ip and choose k3s version.

"playbooks/helm.yaml" — install helm binary to master node.

"playbooks/nginx.yaml" — deploy nginx from helm chart.

"playbooks/deploy.yaml" — deploy our php application.

"playbooks/check.yaml" — just check from localhost, if our deployment success or not. You need to add entry to local hosts file to make the check work.

I hope, this code will help you to make your own application deployments to kubernetes much easier.

Links

License

MIT

k3s-simple-deploy's People

Watchers

Raphael Shukurov 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.