Docker** Kubernetes [#s3f08f98]
# swapoff -a
net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1
[kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg exclude=kube*
cd /usr/bin
RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
chmod a+rx /usr/bin/kube* [Unit] Description=kubelet: The Kubernetes Node Agent Documentation=https://kubernetes.io/docs/ Wants=network-online.target After=network-online.target [Service] ExecStart=/usr/bin/kubelet Restart=always StartLimitInterval=0 RestartSec=10 [Install] WantedBy=multi-user.target
[Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. EnvironmentFile=-/etc/sysconfig/kubelet ExecStart= ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml wget https://docs.projectcalico.org/manifests/custom-resources.yaml vi custom-resources.yaml (correct IP) kubectl create -f custom-resources.yaml watch kubectl get pods -n calico-system kubectl taint nodes --all node-role.kubernetes.io/master- (マスタノードでも Podを実行できるようになる) kubectl get nodes -o wide
[keyfile] unmanaged-devices=interface-name:cali*;interface-name:tunl*;interface-name:vxlan.calico
cd /usr/local/bin curl -o calicoctl -O -L "https://github.com/projectcalico/calicoctl/releases/download/v3.20.0/calicoctl" chmod a+rx calicoctl ln -s calicoctl kubectl-calico
docker pull calico/ctl:v3.20.0
kubectl apply -f https://docs.projectcalico.org/manifests/calicoctl.yaml
kubectl exec -ti -n kube-system calicoctl -- /calicoctl get profiles -o wide
curl -L https://docs.projectcalico.org/manifests/calico.yaml | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ # ADD' | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ - name: FELIX_IPTABLESBACKEND' | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ value: Auto' | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ # ADD' | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ - name: CALICO_IPV4POOL_CIDR' | \ sed '/ - name: CALICO_DISABLE_FILE_LOGGING/i\ value: \"10.128.0.0\/16\"' | \ cat - > calico.yaml kubectl apply -f calico.yaml watch kubectl get pods -n calico-system kubectl taint nodes --all node-role.kubernetes.io/master- kubectl get nodes -o wide
cat <<EOF > /etc/NetworkManager/conf.d/calico.conf [keyfile] unmanaged-devices=interface-name:cali*;interface-name:tunl*;interface-name:vxlan.calico EOF wget https://docs.projectcalico.org/v3.15/manifests/calico.yaml vi calico.yaml (correct IP) kubectl apply -f calico.yaml watch kubectl get pods -n calico-system kubectl taint nodes --all node-role.kubernetes.io/master- kubectl get nodes -o wide
kubectl edit configmap -n kube-system kube-proxy kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/namespace.yaml kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/metallb.yaml kubectl get ns kubectl get pod -n metallb-system kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)" vi l2-configuration.yaml kubectl apply -f l2-configuration.yaml kubectl get service
kubectl run nginx --image=nginx:1.11.3 kubectl get pod kubectl expose pod nginx --port=80 --type=LoadBalancer --name=nginx kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.128.0.1 <none> 443/TCP 17m nginx LoadBalancer 10.128.44.222 172.22.1.70 80:32606/TCP 3m42s
kubectl run nginx --image=nginx:1.11.3 kubectl get pod kubectl expose pod nginx --external-ip=172.22.1.75 --port=80 kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.128.0.1 <none> 443/TCP 15m nginx ClusterIP 10.128.175.104 192.168.27.43 80/TCP 3s
kubectl delete service nginx kubectl get service kubectl delete pod nginx kubectl get pod
# kubectl expose pod nginx --external-ip=172.22.1.75 --port=80 --type=LoadBalancer # kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 80m nginx LoadBalancer 10.107.28.138 172.22.1.75 80:32348/TCP 4s
# kubectl expose pod nginx --port=80 --type=LoadBalancer --name=nginx2 # kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 95m nginx LoadBalancer 10.107.28.138 172.22.1.75 80:32348/TCP 14m nginx2 LoadBalancer 10.107.150.209 <pending> 80:31353/TCP 7s
spec: allocateLoadBalancerNodePorts: true clusterIP: 10.128.90.50 clusterIPs: - 10.128.90.50 externalIPs: - 192.168.27.43 externalTrafficPolicy: Cluster
# kubectl expose pod nginx --port 80 --external-ip=192.168.27.44 --name=nginx2 # kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.128.0.1 <none> 443/TCP 67m nginx ClusterIP 10.128.175.104 192.168.27.43 80/TCP 51m nginx2 ClusterIP 10.128.175.124 192.168.27.44 80/TCP 4m53s