forked from skippbox/kubeadm-centos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
272 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
vars_files: | ||
- vars/local_config.yml | ||
- vars/secrets.yml | ||
|
||
roles: | ||
- common | ||
- k8s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
- vars/secrets.yml | ||
|
||
roles: | ||
- common | ||
- k8s | ||
- common | ||
- k8s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: install ssh key | ||
copy: | ||
content: "{{ key.private_key }}" | ||
dest: "~/.ssh/id_rsa_{{ ssh_key }}" | ||
mode: 0600 | ||
tags: sshkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- name: check if ssh key exists | ||
stat: | ||
path: "~/.ssh/id_rsa_{{ ssh_key }}" | ||
register: stat_ssh_key | ||
tags: sshkey | ||
|
||
- name: Create SSH Key | ||
cs_sshkeypair: | ||
name: "{{ ssh_key }}" | ||
register: key | ||
when: "{{ not stat_ssh_key.stat.exists }}" | ||
notify: install ssh key | ||
tags: sshkey | ||
|
||
- debug: | ||
msg: 'private key is {{ key.private_key }}' | ||
verbosity: 2 | ||
when: not key|skipped | ||
tags: sshkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- include: create_sshkey.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
- name: check if ssh key exists | ||
stat: | ||
path: "~/.ssh/id_rsa_{{ ssh_key }}" | ||
register: stat_ssh_key | ||
tags: sshkey | ||
- name: Create EC2 SSH Key | ||
ec2_key: | ||
name: "{{ ssh_key }}" | ||
region: "{{ aws_region }}" | ||
state: present | ||
register: ec2key | ||
tags: sshkey | ||
|
||
- name: Create SSH Key | ||
cs_sshkeypair: | ||
name: "{{ ssh_key }}" | ||
register: key | ||
when: "{{ not stat_ssh_key.stat.exists }}" | ||
notify: install ssh key | ||
tags: sshkey | ||
- debug: msg='private key is {{ ec2key.key.private_key }}' | ||
when: ec2key.changed | ||
tags: sshkey | ||
|
||
- local_action: copy content="{{ ec2key.key.private_key }}" dest="~/.ssh/id_rsa_{{ ssh_key }}" | ||
when: ec2key.changed | ||
tags: sshkey | ||
|
||
- debug: | ||
msg: 'private key is {{ key.private_key }}' | ||
verbosity: 2 | ||
when: not key|skipped | ||
tags: sshkey | ||
- file: path="~/.ssh/id_rsa_{{ ssh_key }}" mode=0600 | ||
when: ec2key.changed | ||
tags: sshkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
- include: create_sshkey.yml | ||
- include: create_sshkey.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Create k8s context | ||
|
||
- name: Set context cluster | ||
command: kubectl config set-cluster exo --server=https://{{ k8s_master.default_ip }}:443 --insecure-skip-tls-verify=true | ||
tags: context | ||
|
||
- name: Set context user | ||
command: kubectl config set-credentials exo --username={{ k8s_username }} --password={{ k8s_password}} | ||
|
||
- name: Create context | ||
command: kubectl config set-context exo --cluster=exo --user=exo | ||
|
||
- name: Use context | ||
command: kubectl config use-context exo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Create inventory file | ||
|
||
- name: Create inventory file | ||
template: | ||
src: inventory.j2 | ||
dest: ./inventory | ||
tags: inventory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Create k8s security group | ||
|
||
- name: Create k8s Security Group | ||
cs_securitygroup: | ||
name: "{{ k8s_security_group_name }}" | ||
description: k8s |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
- name: Start k8s head node | ||
cs_instance: | ||
name: "{{ k8s_node_prefix }}-head" | ||
template: "{{ k8s_template }}" | ||
service_offering: "{{ k8s_instance_type }}" | ||
ssh_key: "{{ ssh_key }}" | ||
security_groups: | ||
- '{{ k8s_security_group_name }}' | ||
user_data: "{{ lookup('template', '../templates/k8s-master.j2') }}" | ||
register: k8s_master | ||
|
||
- debug: | ||
msg: 'k8s master IP is {{ k8s_master.default_ip }}' | ||
verbosity: 2 | ||
|
||
- name: Start k8s nodes | ||
cs_instance: | ||
name: "{{ k8s_node_prefix }}-node-{{ item }}" | ||
template: "{{ k8s_template }}" | ||
service_offering: "{{ k8s_instance_type }}" | ||
ssh_key: "{{ ssh_key }}" | ||
security_groups: | ||
- '{{ k8s_security_group_name }}' | ||
user_data: "{{ lookup('template', '../templates/k8s-node.j2') }}" | ||
with_sequence: count={{ k8s_num_nodes }} | ||
register: k8s_nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- include: create_secgroup.yml | ||
- include: create_secgroup_rules.yml | ||
- include: create_vm.yml | ||
- include: create_inv.yml | ||
- include: create_context.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[default] | ||
# localhost ansible_python_interpreter=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python | ||
|
||
[master] | ||
master_node ansible_host={{ k8s_master.default_ip }} ansible_ssh_private_key_file=~/.ssh/id_rsa_k8s ansible_ssh_user=centos | ||
|
||
[nodes] | ||
{% for item in k8s_nodes.results %} | ||
{{ item.default_ip }} | ||
{% endfor %} | ||
|
||
[allnodes] | ||
{{ k8s_master.default_ip }} | ||
{% for item in k8s_nodes.results %} | ||
{{ item.default_ip }} | ||
{% endfor %} | ||
|
||
[nodes:vars] | ||
ansible_ssh_user=centos | ||
ansible_ssh_private_key_file=~/.ssh/id_rsa_{{ ssh_key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#cloud-config | ||
write_files: | ||
- path: /etc/yum.repos.d/kubernetes.repo | ||
content: | | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64 | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg | ||
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | ||
|
||
package_update: true | ||
|
||
packages: | ||
- docker | ||
- kubelet | ||
- kubeadm | ||
- kubectl | ||
- kubernetes-cni | ||
|
||
power_state: | ||
mode: reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#cloud-config | ||
write_files: | ||
- path: /etc/yum.repos.d/kubernetes.repo | ||
content: | | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64 | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg | ||
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | ||
|
||
package_update: true | ||
|
||
packages: | ||
- docker | ||
- kubelet | ||
- kubeadm | ||
- kubectl | ||
- kubernetes-cni | ||
|
||
power_state: | ||
mode: reboot |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# Create inventory file | ||
|
||
- name: Create inventory file | ||
template: | ||
src: inventory.j2 | ||
dest: ./inventory | ||
tags: inventory | ||
- name: Create inventory file | ||
template: src=inventory.j2 dest=./inventory | ||
tags: inventory |
Oops, something went wrong.