Skip to content

Commit

Permalink
Prepared project to support qcow2 images in addition to lxc
Browse files Browse the repository at this point in the history
  • Loading branch information
zimmertr committed Oct 22, 2018
1 parent 620bc48 commit 2dd56f9
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 45 deletions.
8 changes: 7 additions & 1 deletion Inventories/Kubernetes_LXC.ini → Inventories/inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ k8s_master
k8s_nodes

[proxmox_server:vars]
ansible_user='root'
ansible_ssh_private_key_file='~/.ssh/sol.milkyway.saturn'
ansible_ssh_common_args: '-o ServerAliveInterval=5 -o StrictHostKeyChecking=no'

[k8s_master:vars]
ansible_user='root'
ansible_ssh_private_key_file='~/.ssh/sol.milkyway.kubernetes'
ansible_ssh_common_args: '-o ServerAliveInterval=5 -o StrictHostKeyChecking=no'

[k8s_nodes:vars]
ansible_ssh_private_key_file='~/.ssh/sol.milkyway.kubernetes'
ansible_user='root'
ansible_ssh_private_key_file='~/.ssh/sol.milkyway.kubernetes'
ansible_ssh_common_args: '-o ServerAliveInterval=5 -o StrictHostKeyChecking=no'
10 changes: 5 additions & 5 deletions Playbooks/deploy_lxc_containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
shell: pvesh create /pools -poolid "{{ k8s_resource_pool }}" --Comment "Kubernetes Cluster made from CentOS 7 Linux Containers"

- name: Downloading the newest CentOS LXC template
shell: pveam download {{ template_storage }} {{ centos_template }}
shell: pveam download {{ template_storage }} {{ lxc_template }}

- name: Provisioning a Kubernetes Master container
shell: >
pct create {{ k8s_master_id }}
{{ template_storage }}:vztmpl/{{ centos_template }}
{{ template_storage }}:vztmpl/{{ lxc_template }}
--pool "{{ k8s_resource_pool }}"
--description "Kubernetes Master"
--hostname "{{ k8s_master_hn }}"
Expand All @@ -32,7 +32,7 @@
- name: Provisioning Kubernetes Node 1 container
shell: >
pct create {{ k8s_node1_id }}
{{ template_storage }}:vztmpl/{{ centos_template }}
{{ template_storage }}:vztmpl/{{ lxc_template }}
--pool "{{ k8s_resource_pool }}"
--description "Kubernetes Node 1"
--hostname "{{ k8s_node1_hn }}"
Expand All @@ -54,7 +54,7 @@
- name: Provisioning Kubernetes Node 2 container
shell: >
pct create {{ k8s_node2_id }}
{{ template_storage }}:vztmpl/{{ centos_template }}
{{ template_storage }}:vztmpl/{{ lxc_template }}
--pool "{{ k8s_resource_pool }}"
--description "Kubernetes Node 2"
--hostname "{{ k8s_node2_hn }}"
Expand All @@ -76,7 +76,7 @@
- name: Provisioning Kubernetes Node 3 container
shell: >
pct create {{ k8s_node3_id }}
{{ template_storage }}:vztmpl/{{ centos_template }}
{{ template_storage }}:vztmpl/{{ lxc_template }}
--pool "{{ k8s_resource_pool }}"
--description "Kubernetes Node 3"
--hostname "{{ k8s_node3_hn }}"
Expand Down
10 changes: 10 additions & 0 deletions Playbooks/deploy_qcow2_vms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- hosts: proxmox_server
tasks:
- name: Create a resource pool
shell: pvesh create /pools -poolid "{{ k8s_resource_pool }}" --Comment "Kubernetes Cluster"

- name: Downloading the newest CentOS LXC template
shell: pveam download {{ template_storage }} {{ lxc_template }}

- name: Provisioning a Kubernetes Master container
15 changes: 15 additions & 0 deletions Playbooks/install_base_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@
- name: Installing the required packages to bootstrap a kubernetes cluster
yum:
name: ['docker-ce', 'kubelet', 'kubeadm', 'kubectl']

- name: Create database for mlocate
shell: updatedb

- name: Enabling the systemd module for docker-ce
systemd:
state: started
name: docker
enabled: yes

- name: Enabling the systemd module for kubelet
systemd:
state: started
name: kubelet
enabled: yes
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@

- hosts: k8s_master:k8s_nodes
tasks:
- name: Create database for mlocate
shell: updatedb

- name: Enabling the systemd module for docker-ce
systemd:
state: started
name: docker
enabled: yes

- name: Enabling the systemd module for kubelet
systemd:
state: started
name: kubelet
enabled: yes

- name: Enabling the systemd module for rc-local
systemd:
state: started
Expand Down
61 changes: 40 additions & 21 deletions Vars/vars.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,102 @@
#The user to run commands as on your Proxmox server.
ansible_user: 'root'
###############################################################################################
# -LXC Options- #
###############################################################################################
# If using LXC containers, these parameters must be filled out. #
###############################################################################################

#The arguments you want to use with SSH
ansible_ssh_common_args: '-o ServerAliveInterval=5 -o StrictHostKeyChecking=no'
# The LXC template to use for your containers. To find the newest release,
# run this command: $pveam available | grep centos-7 | awk '{print $2}'
lxc_template: 'centos-7-default_20171212_amd64.tar.xz'

#The storage to download the LXC containers to.
# The Proxmox storage volume where your template will be stored.
template_storage: 'Hub'

#The LXC template to use for your containers.
#The newest version can be obtained by running this command on your ProxMox server: pveam available | grep centos-7 | awk '{print $2}'
centos_template: 'centos-7-default_20171212_amd64.tar.xz'
###############################################################################################
# -qcow2 Options- #
###############################################################################################
# If using qcow2 images, these parameters must be filled out. #
###############################################################################################

#The resource pool for your containers to be placed in.
# The qcow2 image to use for your Virtual Machines. I believe that this
# link should ALWAYS be the newest release. If you find that it is out of
# date, you can check for a newer image here:
# https://cloud.centos.org/centos/7/images/?C=M;O=D
qcow2_image: 'https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2c'


###############################################################################################
# -Universal Options- #
###############################################################################################
# All of these parameters must be filled out. #
###############################################################################################

# The resource pool for your compute resources to be placed in.
k8s_resource_pool: "Kubernetes"

#The path to the SSH Public Key to use with your containers.
# The path to the SSH Public Key to be used with your compute resources.
k8s_ssh_key: "/root/.ssh/sol.milkyway.kubernetes.pub"

#The IDs for your containers
# The Proxmox IDs for each of your compute resources.
k8s_master_id: '170'
k8s_node1_id: '180'
k8s_node2_id: '181'
k8s_node3_id: '182'

#The hostnames for your containers
# The hostnames for each of your compute resources.
k8s_master_hn: "Pluto"
k8s_node1_hn: "Ceres"
k8s_node2_hn: "Eris"
k8s_node3_hn: "Haumea"

#The memory for each of your containers
# The amount of memory for each of your compute resources.
k8s_master_mem: "4096"
k8s_node1_mem: "8192"
k8s_node2_mem: "8192"
k8s_node3_mem: "8192"

#The disk sizes for your containers.
# The disk sizes for your compute resources.
k8s_master_size: "50G"
k8s_node1_size: "50G"
k8s_node2_size: "50G"
k8s_node3_size: "50G"

#The static ip for each of your containers
# The static ip for each of your compute resources.
k8s_master_ip: "192.168.1.170"
k8s_node1_ip: "192.168.1.180"
k8s_node2_ip: "192.168.1.181"
k8s_node3_ip: "192.168.1.182"

#The subnet size for each of your containers
# The subnet size for each of your compute resources.
k8s_master_sn: "/24"
k8s_node1_sn: "/24"
k8s_node2_sn: "/24"
k8s_node3_sn: "/24"

#The gateway for each of your containers
# The gateway for each of your compute resources.
k8s_master_gw: "192.168.1.1"
k8s_node1_gw: "192.168.1.1"
k8s_node2_gw: "192.168.1.1"
k8s_node3_gw: "192.168.1.1"

#The DNS server for each of your containers
# The DNS server for each of your compute resources.
k8s_master_ns: "192.168.1.10"
k8s_node1_ns: "192.168.1.10"
k8s_node2_ns: "192.168.1.10"
k8s_node3_ns: "192.168.1.10"

#The search domain for each of your containers
# The search domain for each of your compute resources.
k8s_master_sd: "sol.milkyway"
k8s_node1_sd: "sol.milkyway"
k8s_node2_sd: "sol.milkyway"
k8s_node3_sd: "sol.milkyway"

#The network bridge for each of your containers
# The network bridge for each of your compute resources.
k8s_master_bridge: "vmbr0"
k8s_node1_bridge: "vmbr0"
k8s_node2_bridge: "vmbr0"
k8s_node3_bridge: "vmbr0"

#The volume for the container mountpoint to be placed in for your containers.
# The Proxmox storage volume where each of your Compute resources will be stored.
k8s_master_stg: "Proxmox_lvm-thin"
k8s_node1_stg: "SaturnPool"
k8s_node2_stg: "SaturnPool"
Expand Down
17 changes: 14 additions & 3 deletions site.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
#Deploy the LXCs to your Proxmox server
###############################################################################################
# -Deploy the Compute Resources- #
###############################################################################################
# Only one of these playbooks should be used at a time. See the README for more information. #
###############################################################################################
- import_playbook: Playbooks/deploy_lxc_containers.yml
#- import_playbook: Playbooks/deploy_qcow2_vms.yml

#Prepare CentOS for Kubernetes
###############################################################################################
# -Prepare the instances for Kubernetes- #
###############################################################################################
# Upgrade CentOS, install the necessary packages, enable Systemd modules, and reboot the #
# instances. The `privelege_lxc_instances` playbook should only be used if you are deploying #
# containers for your compute resources. See the README for more information. #
###############################################################################################
- import_playbook: Playbooks/install_base_packages.yml
- import_playbook: Playbooks/perform_miscellaneous_tasks.yml
- import_playbook: Playbooks/privelege_lxc_instances.yml

#Bootstrap Kubernetes
- import_playbook: Playbooks/bootstrap_kubernetes.yml

0 comments on commit 2dd56f9

Please sign in to comment.