新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
42
learn/learn-kubernetes-master/kiamol/ch01/vagrant/README.md
Normal file
42
learn/learn-kubernetes-master/kiamol/ch01/vagrant/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Using Vagrant to run KinD
|
||||
|
||||
This configures a virtual machine which installs Docker and KinD.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
You need to install [Vagrant](https://www.vagrantup.com) and use one of the supported VM providers:
|
||||
|
||||
* Hyper-V on Windows
|
||||
* VirtualBox on Linux, Windows or Mac
|
||||
|
||||
> Pull requests to add support for other providers is welcome :)
|
||||
|
||||
## Usage
|
||||
|
||||
From this directory run:
|
||||
|
||||
```
|
||||
vagrant up
|
||||
```
|
||||
|
||||
The first time you run this it will take a while to download the base VM, but subsequent runs will be fast.
|
||||
|
||||
Connect to the VM:
|
||||
|
||||
```
|
||||
vagrant ssh
|
||||
```
|
||||
|
||||
The VM mounts the `kiamol` folder on your host into the VM, so you can get to all the source for the book from here:
|
||||
|
||||
```
|
||||
cd /kiamol
|
||||
```
|
||||
|
||||
## Teardown
|
||||
|
||||
Use one of these options:
|
||||
|
||||
* `vagrant suspend` to suspend the VM which keeps your current state
|
||||
* `vagrant halt` to stop the VM
|
||||
* `vagrant destroy` to remove the VM altogether
|
||||
26
learn/learn-kubernetes-master/kiamol/ch01/vagrant/Vagrantfile
vendored
Normal file
26
learn/learn-kubernetes-master/kiamol/ch01/vagrant/Vagrantfile
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
config.vm.define "kiamol" do |kiamol|
|
||||
kiamol.vm.box = "bento/ubuntu-16.04" # 20.04 uses resolved which messes with Kind's DNS
|
||||
kiamol.vm.hostname = "kiamol"
|
||||
kiamol.vm.network "private_network", type: "dhcp"
|
||||
|
||||
kiamol.vm.provision "shell", path: "setup.sh"
|
||||
kiamol.vm.provision "shell", path: "kiamol.sh", privileged: false
|
||||
|
||||
kiamol.vm.synced_folder "../..", "/kiamol"
|
||||
|
||||
kiamol.vm.provider :hyperv do |v|
|
||||
v.vmname = "kiamol"
|
||||
v.maxmemory = 3000
|
||||
v.cpus = 2
|
||||
end
|
||||
|
||||
kiamol.vm.provider :virtualbox do |v|
|
||||
v.name = "kiamol"
|
||||
v.memory = 3000
|
||||
v.cpus = 2
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
17
learn/learn-kubernetes-master/kiamol/ch01/vagrant/kiamol.sh
Normal file
17
learn/learn-kubernetes-master/kiamol/ch01/vagrant/kiamol.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo '---------'
|
||||
echo "kiamol.sh as: $(whoami)"
|
||||
echo '---------'
|
||||
|
||||
# create the cluster
|
||||
mkdir -p ~/.kube
|
||||
sudo kind create cluster --image kindest/node:v1.18.8 --name kiamol --kubeconfig /home/vagrant/.kube/config
|
||||
sudo chown vagrant ~/.kube/config
|
||||
|
||||
# set MOTD
|
||||
sudo sh -c 'echo "\n** Learn Kubernetes in a Month of Lunches **\n** https://kiamol.net **\nSource is in /kiamol\nIf Kubectl does not respond, start the Kind container with:\n docker start kiamol-control-plane\n" > /etc/motd'
|
||||
|
||||
# add aliases:
|
||||
echo "alias k='kubectl'" >> ~/.bashrc
|
||||
echo "alias d='docker'" >> ~/.bashrc
|
||||
53
learn/learn-kubernetes-master/kiamol/ch01/vagrant/setup.sh
Normal file
53
learn/learn-kubernetes-master/kiamol/ch01/vagrant/setup.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo '--------'
|
||||
echo "setup.sh as: $(whoami)"
|
||||
echo '--------'
|
||||
|
||||
DOCKER_VERSION="5:19.03.12~3-0~ubuntu-xenial"
|
||||
KUBERNETES_VERSION="1.18.8-00"
|
||||
hostname -I | awk '{print $NF}' > /tmp/ip.txt
|
||||
|
||||
# turn off swap - for the Kubelet
|
||||
swapoff -a
|
||||
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
|
||||
|
||||
# install Docker
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg-agent \
|
||||
software-properties-common
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||
add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
docker-ce=$DOCKER_VERSION \
|
||||
docker-ce-cli=$DOCKER_VERSION \
|
||||
containerd.io
|
||||
|
||||
# use Docker & Kind without sudo:
|
||||
sudo usermod -aG docker vagrant
|
||||
|
||||
# install Kubectl
|
||||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
||||
add-apt-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
kubectl=$KUBERNETES_VERSION
|
||||
|
||||
# install Helm
|
||||
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
|
||||
|
||||
# install Kind
|
||||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-$(uname)-amd64
|
||||
chmod +x ./kind
|
||||
mv ./kind /usr/local/bin/kind
|
||||
Reference in New Issue
Block a user