kubeadm: make it also work on CentOS 7
Change-Id: I6fe3c3445844597bfd1b603c1a97687d550f5e87
This commit is contained in:
parent
e4f22b14f3
commit
e865f190f5
|
@ -14,6 +14,7 @@
|
|||
|
||||
function base_install {
|
||||
if [ "x$HOST_OS" == "xubuntu" ]; then
|
||||
sudo apt-add-repository --yes ppa:ansible/ansible
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
iproute2 \
|
||||
|
@ -21,7 +22,8 @@ function base_install {
|
|||
ipcalc \
|
||||
nmap \
|
||||
lshw \
|
||||
screen
|
||||
screen \
|
||||
ansible
|
||||
elif [ "x$HOST_OS" == "xcentos" ]; then
|
||||
sudo yum install -y \
|
||||
epel-release
|
||||
|
@ -31,14 +33,16 @@ function base_install {
|
|||
iptables \
|
||||
initscripts \
|
||||
nmap \
|
||||
lshw
|
||||
lshw \
|
||||
ansible
|
||||
elif [ "x$HOST_OS" == "xfedora" ]; then
|
||||
sudo dnf install -y \
|
||||
iproute \
|
||||
iptables \
|
||||
ipcalc \
|
||||
nmap \
|
||||
lshw
|
||||
lshw \
|
||||
ansible
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -6,19 +6,16 @@
|
|||
gather_facts: false
|
||||
|
||||
pre_tasks:
|
||||
- name: install python 2
|
||||
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
|
||||
- name: Install packages
|
||||
package: name={{ item }} state=present update_cache=yes
|
||||
with_items:
|
||||
- python
|
||||
- unzip
|
||||
- httpie
|
||||
|
||||
- name: Gather facts after python installation
|
||||
setup: filter=ansible_*
|
||||
|
||||
- name: Install packages
|
||||
apt: name={{ item }} state=present update_cache=yes
|
||||
with_items:
|
||||
- ansible
|
||||
- unzip
|
||||
- httpie
|
||||
|
||||
roles:
|
||||
- docker
|
||||
- k8s_cli
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
- name: Set up docker stable repository on CentOS
|
||||
yum_repository:
|
||||
name: docker-ce-stable
|
||||
description: Docker CE Stable - $basearch
|
||||
baseurl: https://download.docker.com/linux/centos/7/$basearch/stable
|
||||
enabled: yes
|
||||
gpgcheck: yes
|
||||
gpgkey: https://download.docker.com/linux/centos/gpg
|
||||
|
||||
- name: Install docker-ce
|
||||
# yum:
|
||||
# name: docker-ce-17.03.2.ce
|
||||
# state: present
|
||||
# update_cache: yes
|
||||
# NOTE(huntxu): This workaround is required for docker-ce-17.03.2 as its
|
||||
# dependency docker-ce-selinux is marked as obsolete. Hopefully this can
|
||||
# be removed once a newer version of docker can be used.
|
||||
shell: yum install -y --setopt=obsoletes=0 \
|
||||
docker-ce-17.03.2.ce-1.el7.centos \
|
||||
docker-ce-selinux-17.03.2.ce-1.el7.centos
|
||||
|
||||
- name: Ensure docker.service.d directory
|
||||
file:
|
||||
path: /etc/systemd/system/docker.service.d
|
||||
recurse: yes
|
||||
state: directory
|
||||
|
||||
- name: Change docker cgroup driver
|
||||
copy:
|
||||
content: |
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/dockerd --exec-opt native.cgroupdriver=systemd
|
||||
dest: /etc/systemd/system/docker.service.d/10-docker-kubeadm.conf
|
||||
mode: 0644
|
||||
group: root
|
||||
owner: root
|
||||
|
||||
- name: Restart docker service
|
||||
systemd:
|
||||
name: docker
|
||||
daemon_reload: yes
|
||||
state: restarted
|
|
@ -1,21 +1,14 @@
|
|||
---
|
||||
- name: Install packages
|
||||
apt: name={{ item }} state=present update_cache=yes
|
||||
package: name={{ item }} state=present update_cache=yes
|
||||
with_items:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
|
||||
- name: Add Docker’s official GPG key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
- include: ubuntu.yml
|
||||
when:
|
||||
ansible_pkg_mgr == 'apt'
|
||||
|
||||
- name: Set up the stable repository
|
||||
apt_repository: repo='deb https://download.docker.com/linux/ubuntu xenial stable' state=present
|
||||
|
||||
- name: Install docker-ce
|
||||
apt:
|
||||
name: docker-ce={{ docker_version }}
|
||||
state: present
|
||||
update_cache: yes
|
||||
- include: centos.yml
|
||||
when:
|
||||
ansible_pkg_mgr == 'yum'
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- name: Install APT transport-https
|
||||
apt:
|
||||
name: apt-transport-https
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Add Docker’s official GPG key
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
|
||||
- name: Set up the stable repository
|
||||
apt_repository:
|
||||
repo: 'deb https://download.docker.com/linux/ubuntu xenial stable'
|
||||
state: present
|
||||
|
||||
- name: Install docker-ce
|
||||
apt:
|
||||
name: docker-ce={{ docker_version }}
|
||||
state: present
|
||||
update_cache: yes
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
- name: Set up Kubernetes repository
|
||||
yum_repository:
|
||||
name: kubernetes
|
||||
description: Kubernetes
|
||||
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
|
||||
enabled: yes
|
||||
gpgcheck: yes
|
||||
repo_gpgcheck: yes
|
||||
gpgkey:
|
||||
- https://packages.cloud.google.com/yum/doc/yum-key.gpg
|
||||
- https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
- name: Add Kubernetes GPG key
|
||||
apt_key:
|
||||
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
|
||||
state: present
|
||||
- include: ubuntu.yml
|
||||
when:
|
||||
ansible_pkg_mgr == 'apt'
|
||||
|
||||
- name: Set up Kubernetes repository
|
||||
apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present
|
||||
- include: centos.yml
|
||||
when:
|
||||
ansible_pkg_mgr == 'yum'
|
||||
|
||||
- name: Install kube CLIs
|
||||
apt:
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
@ -17,4 +17,10 @@
|
|||
- kubeadm
|
||||
- kubectl
|
||||
|
||||
- import_tasks: install_kube_prompt_tasks.yml
|
||||
- name: Start kubelet
|
||||
systemd:
|
||||
name: kubelet
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
|
||||
- import_tasks: install_kube_prompt_tasks.yml
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Add Kubernetes GPG key
|
||||
apt_key:
|
||||
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
|
||||
state: present
|
||||
|
||||
- name: Set up Kubernetes repository
|
||||
apt_repository:
|
||||
repo: 'deb http://apt.kubernetes.io/ kubernetes-xenial main'
|
||||
state: present
|
|
@ -24,7 +24,6 @@ net_resolv_pre_kube
|
|||
net_hosts_pre_kube
|
||||
|
||||
# Setup the K8s Cluster
|
||||
sudo apt-add-repository --yes ppa:ansible/ansible && sudo apt-get update -y -qq && sudo apt-get install ansible -y -qq
|
||||
ansible-playbook ${WORK_DIR}/tools/gate/kubeadm/playbook/deploy_k8s.yaml
|
||||
|
||||
# waits until kubectl can access the api server
|
||||
|
|
Loading…
Reference in New Issue