Skip to content

Commit f44b072

Browse files
authored
Merge pull request containerd#4593 from dmcgowan/merge-cri
Merge cri master
2 parents de546a1 + 1c60ae7 commit f44b072

File tree

302 files changed

+25708
-649
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+25708
-649
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ jobs:
116116
else
117117
DCO_RANGE=$(curl ${GITHUB_COMMIT_URL} | jq -r '.[0].parents[0].sha + "..HEAD"')
118118
fi
119-
../project/script/validate/dco
119+
# Add back after CRI merge complete and remove last call
120+
# ../project/script/validate/dco
121+
echo "skipping for CRI merge since older commits may not pass this check"
120122
121123
- name: Headers
122124
run: ../project/script/validate/fileheader ../project/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revi
8585
SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)'
8686

8787
# Project packages.
88-
PACKAGES=$(shell go list ${GO_TAGS} ./... | grep -v /vendor/)
88+
PACKAGES=$(shell go list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration)
8989
INTEGRATION_PACKAGE=${PKG}
9090
TEST_REQUIRES_ROOT_PACKAGES=$(filter \
9191
${PACKAGES}, \

cmd/containerd/builtins_cri.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
package main
2020

21-
import _ "github.com/containerd/cri"
21+
import _ "github.com/containerd/containerd/pkg/cri"

contrib/ansible/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Kubernetes Cluster with Containerd
2+
<p align="center">
3+
<img src="https://kubernetes.io/images/favicon.png" width="50" height="50">
4+
<img src="https://containerd.io/img/logos/icon/black/containerd-icon-black.png" width="50" >
5+
</p>
6+
7+
8+
This document provides the steps to bring up a Kubernetes cluster using ansible and kubeadm tools.
9+
10+
### Prerequisites:
11+
- **OS**: Ubuntu 16.04 (will be updated with additional distros after testing)
12+
- **Python**: 2.7+
13+
- **Ansible**: 2.4+
14+
15+
## Step 0:
16+
- Install Ansible on the host where you will provision the cluster. This host may be one of the nodes you plan to include in your cluster. Installation instructions for Ansible are found [here](http://docs.ansible.com/ansible/latest/intro_installation.html).
17+
- Create a hosts file and include the IP addresses of the hosts that need to be provisioned by Ansible.
18+
```console
19+
$ cat hosts
20+
172.31.7.230
21+
172.31.13.159
22+
172.31.1.227
23+
```
24+
- Setup passwordless SSH access from the host where you are running Ansible to all the hosts in the hosts file. The instructions can be found in [here](http://www.linuxproblem.org/art_9.html)
25+
26+
## Step 1:
27+
At this point, the ansible playbook should be able to ssh into the machines in the hosts file.
28+
```console
29+
git clone https://github.com/containerd/cri
30+
cd ./cri/contrib/ansible
31+
ansible-playbook -i hosts cri-containerd.yaml
32+
```
33+
A typical cloud login might have a username and private key file, in which case the following can be used:
34+
```console
35+
ansible-playbook -i hosts -u <username> --private-key <example.pem> cri-containerd.yaml
36+
```
37+
For more options ansible config file (/etc/ansible/ansible.cfg) can be used to set defaults. Please refer to [Ansible options](http://docs.ansible.com/ansible/latest/intro_configuration.html) for advanced ansible configurations.
38+
39+
At the end of this step, you will have the required software installed in the hosts to bringup a kubernetes cluster.
40+
```console
41+
PLAY RECAP ***************************************************************************************************************************************************************
42+
172.31.1.227 : ok=21 changed=7 unreachable=0 failed=0
43+
172.31.13.159 : ok=21 changed=7 unreachable=0 failed=0
44+
172.31.7.230 : ok=21 changed=7 unreachable=0 failed=0
45+
```
46+
47+
## Step 2:
48+
Use [kubeadm](https://kubernetes.io/docs/setup/independent/install-kubeadm/) to bring up a Kubernetes Cluster. Depending on what third-party provider you choose, you might have to set the ```--pod-network-cidr``` to something provider-specific.
49+
Initialize the cluster from one of the nodes (Note: This node will be the master node):
50+
```console
51+
$sudo kubeadm init --skip-preflight-checks
52+
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
53+
[init] Using Kubernetes version: v1.7.6
54+
[init] Using Authorization modes: [Node RBAC]
55+
[preflight] Skipping pre-flight checks
56+
[kubeadm] WARNING: starting in 1.8, tokens expire after 24 hours by default (if you require a non-expiring token use --token-ttl 0)
57+
[certificates] Generated CA certificate and key.
58+
[certificates] Generated API server certificate and key.
59+
[certificates] API Server serving cert is signed for DNS names [abhi-k8-ubuntu-1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 172.31.7.230]
60+
[certificates] Generated API server kubelet client certificate and key.
61+
[certificates] Generated service account token signing key and public key.
62+
[certificates] Generated front-proxy CA certificate and key.
63+
[certificates] Generated front-proxy client certificate and key.
64+
[certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki"
65+
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf"
66+
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
67+
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf"
68+
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf"
69+
[apiclient] Created API client, waiting for the control plane to become ready
70+
[apiclient] All control plane components are healthy after 42.002391 seconds
71+
[token] Using token: 43a25d.420ff2e06336e4c1
72+
[apiconfig] Created RBAC rules
73+
[addons] Applied essential addon: kube-proxy
74+
[addons] Applied essential addon: kube-dns
75+
76+
Your Kubernetes master has initialized successfully!
77+
78+
To start using your cluster, you need to run (as a regular user):
79+
80+
mkdir -p $HOME/.kube
81+
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
82+
sudo chown $(id -u):$(id -g) $HOME/.kube/config
83+
84+
You should now deploy a pod network to the cluster.
85+
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
86+
http://kubernetes.io/docs/admin/addons/
87+
88+
You can now join any number of machines by running the following on each node
89+
as root:
90+
91+
kubeadm join --token 43a25d.420ff2e06336e4c1 172.31.7.230:6443
92+
93+
```
94+
## Step 3:
95+
Use kubeadm join to add each of the remaining nodes to your cluster. (Note: Uses token that was generated during cluster init.)
96+
```console
97+
$sudo kubeadm join --token 43a25d.420ff2e06336e4c1 172.31.7.230:6443 --skip-preflight-checks
98+
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
99+
[preflight] Skipping pre-flight checks
100+
[discovery] Trying to connect to API Server "172.31.7.230:6443"
101+
[discovery] Created cluster-info discovery client, requesting info from "https://172.31.7.230:6443"
102+
[discovery] Cluster info signature and contents are valid, will use API Server "https://172.31.7.230:6443"
103+
[discovery] Successfully established connection with API Server "172.31.7.230:6443"
104+
[bootstrap] Detected server version: v1.7.6
105+
[bootstrap] The server supports the Certificates API (certificates.k8s.io/v1beta1)
106+
[csr] Created API client to obtain unique certificate for this node, generating keys and certificate signing request
107+
[csr] Received signed certificate from the API server, generating KubeConfig...
108+
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
109+
110+
Node join complete:
111+
* Certificate signing request sent to master and response
112+
received.
113+
* Kubelet informed of new secure connection details.
114+
115+
Run 'kubectl get nodes' on the master to see this machine join.
116+
```
117+
At the end of Step 3 you should have a kubernetes cluster up and running and ready for deployment.
118+
119+
## Step 4:
120+
Please follow the instructions [here](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#pod-network) to deploy CNI network plugins and start a demo app.
121+
122+
We are constantly striving to improve the installer. Please feel free to open issues and provide suggestions to make the installer fast and easy to use. We are open to receiving help in validating and improving the installer on different distros.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
- hosts: all
3+
become: true
4+
tasks:
5+
- include_vars: vars/vars.yaml # Contains tasks variables for installer
6+
- include_tasks: tasks/bootstrap_ubuntu.yaml # Contains tasks bootstrap components for ubuntu systems
7+
when: ansible_distribution == "Ubuntu"
8+
- include_tasks: tasks/bootstrap_centos.yaml # Contains tasks bootstrap components for centos systems
9+
when: ansible_distribution == "CentOS"
10+
- include_tasks: tasks/k8s.yaml # Contains tasks kubernetes component installation
11+
- include_tasks: tasks/binaries.yaml # Contains tasks for pulling containerd components
12+
13+
- name: "Create a directory for containerd config"
14+
file: path=/etc/containerd state=directory
15+
16+
- name: "Start Containerd"
17+
systemd: name=containerd daemon_reload=yes state=started enabled=yes
18+
19+
- name: "Load br_netfilter kernel module"
20+
modprobe:
21+
name: br_netfilter
22+
state: present
23+
24+
- name: "Set bridge-nf-call-iptables"
25+
sysctl:
26+
name: net.bridge.bridge-nf-call-iptables
27+
value: 1
28+
29+
- name: "Set ip_forward"
30+
sysctl:
31+
name: net.ipv4.ip_forward
32+
value: 1
33+
34+
- name: "Check kubelet args in kubelet config (Ubuntu)"
35+
shell: grep "^Environment=\"KUBELET_EXTRA_ARGS=" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf || true
36+
register: check_args
37+
when: ansible_distribution == "Ubuntu"
38+
39+
- name: "Add runtime args in kubelet conf (Ubuntu)"
40+
lineinfile:
41+
dest: "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"
42+
line: "Environment=\"KUBELET_EXTRA_ARGS= --runtime-cgroups=/system.slice/containerd.service --container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock\""
43+
insertafter: '\[Service\]'
44+
when: ansible_distribution == "Ubuntu" and check_args.stdout == ""
45+
46+
- name: "Check kubelet args in kubelet config (CentOS)"
47+
shell: grep "^Environment=\"KUBELET_EXTRA_ARGS=" /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf || true
48+
register: check_args
49+
when: ansible_distribution == "CentOS"
50+
51+
- name: "Add runtime args in kubelet conf (CentOS)"
52+
lineinfile:
53+
dest: "/usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf"
54+
line: "Environment=\"KUBELET_EXTRA_ARGS= --runtime-cgroups=/system.slice/containerd.service --container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock\""
55+
insertafter: '\[Service\]'
56+
when: ansible_distribution == "CentOS" and check_args.stdout == ""
57+
58+
- name: "Start Kubelet"
59+
systemd: name=kubelet daemon_reload=yes state=started enabled=yes
60+
61+
# TODO This needs to be removed once we have consistent concurrent pull results
62+
- name: "Pre-pull pause container image"
63+
shell: |
64+
/usr/local/bin/ctr pull k8s.gcr.io/pause:3.2
65+
/usr/local/bin/crictl --runtime-endpoint unix:///run/containerd/containerd.sock \
66+
pull k8s.gcr.io/pause:3.2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Get Containerd"
3+
unarchive:
4+
src: "https://storage.googleapis.com/cri-containerd-release/cri-containerd-{{ containerd_release_version }}.linux-amd64.tar.gz"
5+
dest: "/"
6+
remote_src: yes
7+
8+
- name: "Create a directory for cni binary"
9+
file: path={{ cni_bin_dir }} state=directory
10+
11+
- name: "Create a directory for cni config files"
12+
file: path={{ cni_conf_dir }} state=directory
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Install required packages on CentOS "
3+
yum:
4+
name: "{{ item }}"
5+
state: latest
6+
with_items:
7+
- unzip
8+
- tar
9+
- btrfs-progs
10+
- libseccomp
11+
- util-linux
12+
- libselinux-python
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Install required packages on Ubuntu"
3+
package:
4+
name: "{{ item }}"
5+
state: latest
6+
with_items:
7+
- unzip
8+
- tar
9+
- apt-transport-https
10+
- btrfs-tools
11+
- libseccomp2
12+
- util-linux

contrib/ansible/tasks/k8s.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- name: "Add gpg key (Ubuntu)"
3+
apt_key:
4+
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
5+
state: present
6+
when: ansible_distribution == "Ubuntu"
7+
8+
- name: "Add kubernetes source list (Ubuntu)"
9+
apt_repository:
10+
repo: "deb http://apt.kubernetes.io/ kubernetes-{{ ansible_distribution_release }} main"
11+
state: present
12+
filename: "kubernetes"
13+
when: ansible_distribution == "Ubuntu"
14+
15+
- name: "Update the repository cache (Ubuntu)"
16+
apt:
17+
update_cache: yes
18+
when: ansible_distribution == "Ubuntu"
19+
20+
- name: "Add Kubernetes repository and install gpg key (CentOS)"
21+
yum_repository:
22+
name: kubernetes
23+
description: Kubernetes repository
24+
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
25+
gpgcheck: yes
26+
enabled: yes
27+
repo_gpgcheck: yes
28+
gpgkey:
29+
- https://packages.cloud.google.com/yum/doc/yum-key.gpg
30+
- https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
31+
when: ansible_distribution == "CentOS"
32+
33+
- name: "Disable SELinux (CentOS)"
34+
selinux:
35+
state: disabled
36+
when: ansible_distribution == "CentOS"
37+
38+
- name: "Install kubelet,kubeadm,kubectl (CentOS)"
39+
yum: state=present name={{ item }}
40+
with_items:
41+
- kubelet
42+
- kubeadm
43+
- kubectl
44+
when: ansible_distribution == "CentOS"
45+
46+
- name: "Install kubelet, kubeadm, kubectl (Ubuntu)"
47+
apt: name={{item}} state=installed
48+
with_items:
49+
- kubelet
50+
- kubeadm
51+
- kubectl
52+
when: ansible_distribution == "Ubuntu"

contrib/ansible/vars/vars.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
containerd_release_version: 1.3.0
3+
cni_bin_dir: /opt/cni/bin/
4+
cni_conf_dir: /etc/cni/net.d/

0 commit comments

Comments
 (0)