Git Product home page Git Product logo

ansible-devops's Introduction

Kubernetes Setup Using Ansible

Why Use Ansible?

Ansible is an infrastructure automation engine that automates software configuration management. It is agentless and allows us to use SSH keys for connecting to remote machines. Ansible playbooks are written in yaml and offer inventory management in simple text files.

Prerequisites

  1. Ansible should be installed in your machine. Refer to the Ansible installation guide for platform specific installation.

  2. SSH-Based login should be config between control-node and managed-node. Refer to How To Configure SSH Key-Based Authentication on a Linux Server

Hardware Prerequisites

Harbor

Resource Minimum Recommended
CPU 2 CPU 4 CPU
Mem 4 GB 8 GB
Disk 40 GB 160 GB

Jenkins

Resource Minimum Recommended
Mem 256 MB 4 GB
Disk 1 GB 50 GB

Gitlab

Resource Minimum Recommended
CPU 4 CPU 8 CPU
Mem 4 GB 8 GB
Disk 2.5 GB

Kubernetes

2 GB or more of RAM per machine
2 CPUs or more per machine

OS Prerequisites

Ubuntu Server 22.04.2 LTS

Feature List

  • Support container runtime:
    • Docker
    • Containerd
  • Kubernetes addons:
    • Helm
    • Metrics Server
    • Nginx Ingress Controller
    • Kubernetes Dashboard
    • Cert Manager
  • Support container network:
    • Calico
  • Support network file system:
    • Linux NFS
  • CICD:
    • Harbor
    • Jenkins
    • GitLab
  • Data center:
    • Grafana UI
    • InfluxDB
    • Minio
    • Elasticsearch
    • Redis master replicas

Usage

Install Ansible

sudo sh install.sh

Setup Platform (single mode)

# ---------------------------------------------------------------------------
# check ansible hosts can communication with each other 
ansible -i single-hosts.inventory all -m ping
# ---------------------------------------------------------------------------
# install kubernetes environment
ansible-playbook -i single-hosts.inventory ../playbook/setup-kubernetes.yml
# remove kubernetes master node taint
sudo kubectl taint nodes $(sudo kubectl get nodes --selector=node-role.kubernetes.io/master -o jsonpath='{.items[].metadata.name}') node-role.kubernetes.io/master:NoSchedule-
# install cicd environment
ansible-playbook -i single-hosts.inventory ../playbook/setup-cicd.yml

Reset Platform (single mode)

# ---------------------------------------------------------------------------
# check ansible hosts can communication with each other 
ansible -i single-hosts.inventory all -m ping
# ---------------------------------------------------------------------------
# reset cicd environment
ansible-playbook -i single-hosts.inventory ../playbook/reset-cicd.yml
# reset kubernetes environment
ansible-playbook -i single-hosts.inventory ../playbook/reset-kubernetes.yml

Setup Platform (cluster mode)

# ---------------------------------------------------------------------------
# check ansible hosts can communication with each other 
ansible -i multiple-hosts.inventory all -m ping
# ---------------------------------------------------------------------------
# install cicd environment
ansible-playbook -i multiple-hosts.inventory ../playbook/setup-cicd.yml
# install kubernetes environment
ansible-playbook -i multiple-hosts.inventory ../playbook/setup-kubernetes.yml

Reset Platform (cluster mode)

# ---------------------------------------------------------------------------
# check ansible hosts can communication with each other 
ansible -i multiple-hosts.inventory all -m ping
# ---------------------------------------------------------------------------
# reset kubernetes environment
ansible-playbook -i multiple-hosts.inventory ../playbook/reset-kubernetes.yml
# reset cicd environment
ansible-playbook -i multiple-hosts.inventory ../playbook/reset-cicd.yml

FAQ

How to access kubernetes dashboard

sudo kubectl -n kube-system get secret $(sudo kubectl -n kube-system get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"

Access jenkins

cat /var/lib/jenkins/secrets/initialAdminPassword
admin/password

Access gitlab

By default, a Linux package installation automatically generates a password for the initial administrator user account ( root) and stores it to /etc/gitlab/initial_root_password for at least 24 hours. For security reasons, after 24 hours, this file is automatically removed by the first gitlab-ctl reconfigure.

cat /etc/gitlab/initial_root_password

Ingress hostname

Service name hostname
Kubernetes dashboard dashboard.kubernetes.cluster.com
Minio minio.kubernetes.cluster.com
InfluxDB influxdb.kubernetes.cluster.com
Grafana grafana.kubernetes.cluster.com

ansible-devops's People

Contributors

pedro-abundio-wang avatar

Watchers

 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.