This document discusses deploying Kubernetes on bare metal servers using Container Linux (CoreOS). It describes why bare metal and Container Linux are used, how to deploy the Kubernetes control plane and worker nodes, and how to configure Kubernetes components. The deployment uses CoreOS, etcd, flannel, and TLS assets to set up a highly available Kubernetes cluster on bare metal servers without virtualization. Matchbox can also be used for provisioning nodes by generating Ignition configs from profiles, groups and templates.
2. Copyright 2017 ITRI 工業技術研究院
Agenda
• Why bare metal?
• Why Container Linux?
• How to deployment?
• Conclusion
2
3. Copyright 2017 ITRI 工業技術研究院
Why bare metal?
• Hardware can’t support virtualization
▪ CPU Model: Dual Core AMD Opteron(tm) Processor 270
• Better performance
▪ Bare metal vs. VM
3
4. Copyright 2017 ITRI 工業技術研究院
Why Container Linux (CoreOS)?
• Lightweight Linux
• Container optimized OS
• Security focused
• Auto update
• Integrated well with Kubernetes
4
5. Copyright 2017 ITRI 工業技術研究院
Agenda
• Why bare metal?
• Why Container Linux?
• How to deployment?
• Conclusion
5
8. Copyright 2017 ITRI 工業技術研究院
CoreOS + Kubernetes Steps
• Install CoreOS
• Setup an etcd cluster
• Generate the certificates for Kubernetes components
• Deploy a controller (master) node
• Deploy worker nodes
• Configure kubectl to work with our cluster
• Deploy the add-ons
▪ DNS
▪ Dashboard
8
9. Copyright 2017 ITRI 工業技術研究院
Install CoreOS
• PXE and iPXE
▪ Booting with iPXE
▪ Booting with PXE
▪ Required RAM :1024M+
• Disk
▪ Installing to Disk
Boot from
PXE or iPXE
Boot from ISO
Install to Disk
coreos-install -d /dev/sda -c cloud-config.yaml
9
10. Copyright 2017 ITRI 工業技術研究院
What’s etcd?
• Distributed key, value store
• Used for configuration and monitoring store
• Used for Service discovery
• JSON/REST API
10
12. Copyright 2017 ITRI 工業技術研究院
What’s flannel?
• A virtual network
that gives a
subnet to each
host for use with
container
runtimes
12
13. Copyright 2017 ITRI 工業技術研究院
Deployment Options
• MASTER_HOST
▪ Publicly routable IP of master node.
a. Worker nodes must be able to reach the
master node(s) via this address on port
443
▪ Multiple master nodes
a. Network load balancer
b. DNS configure
• ETCD_ENDPOINTS
▪ List of etcd machines
(http://ip1:port,http://ip2:port,http://ip3:p
ort)
• POD_NETWORK=10.2.0.0/16
▪ The flannel overlay network will provide
routing to this network.
• SERVICE_IP_RANGE=10.3.0.0/24
▪ The CIDR network to use for service
cluster VIPs (Virtual IPs)
▪ Handled by a local kube-proxy service to
each host
• K8S_SERVICE_IP=10.3.0.1
▪ The VIP (Virtual IP) address of the
Kubernetes API Service.
• DNS_SERVICE_IP=10.3.0.10
▪ The VIP (Virtual IP) address of the cluster
DNS service.
13
14. Copyright 2017 ITRI 工業技術研究院
Generate Kubernetes TLS Assets
• Root CA Public Key
▪ ca.pem
• API Server Public & Private Keys
▪ apiserver.pem
▪ apiserver-key.pem
• Worker Node Public & Private Keys
▪ ${WORKER_FQDN}-worker.pem
▪ ${WORKER_FQDN}-worker-key.pem
• Cluster Admin Public & Private Keys
▪ admin.pem
▪ admin-key.pem
https://coreos.com/kubernetes/docs/latest/openssl.html
14
15. Copyright 2017 ITRI 工業技術研究院
Deploy Kubernetes Master Node
• Configure Service Components
▪ TLS Assets
▪ Network Configuration
▪ Docker Configuration
▪ Create the kubelet Unit
▪ Set Up the kube-* Pod
a. kube-apiserver
b. kube-proxy
c. kube-controller-manager
d. kube-scheduler
• Start Services
▪ Load Changed Units
▪ Configure flannel Network
▪ Start kubelet
▪ Basic Health Checks
15
18. Copyright 2017 ITRI 工業技術研究院
Kubelet Unit and Kube-* PODs
/etc/systemd/system/
kubelet.service
/usr/lib/coreos/kubelet-wrapper
--pod-manifest-path=/etc/kubernetes/manifests
Hyperkube
/etc/kubernetes/manifests/kube-apiserver.yaml
/etc/kubernetes/manifests/kube-proxy.yaml
/etc/kubernetes/manifests/kube-controller-manager.yaml
/etc/kubernetes/manifests/kube-scheduler.yaml
An all-in-one binary for the
Kubernetes server
components
18
20. Copyright 2017 ITRI 工業技術研究院
Deploy Kubernetes Worker Node
• Configure Service Components
▪ TLS Assets
▪ Networking Configuration
▪ Docker Configuration
▪ Create the kubelet Unit
▪ Set Up the kube-proxy Pod
▪ Set Up kubeconfig
• Start Services
▪ Load Changed Units
▪ Start kubelet, and flannel
20
22. Copyright 2017 ITRI 工業技術研究院
Kubelet Unit and kube-proxy/kubeconfig
/etc/systemd/system/
kubelet.service
/usr/lib/coreos/kubelet-wrapper
--api-servers=https://${MASTER_HOST}
--kubeconfig=/etc/kubernetes/worker-kubeconfig.yaml
--pod-manifest-path=/etc/kubernetes/manifests
Hyperkube
/etc/kubernetes/manifests/kube-proxy.yaml
An all-in-one binary for the
Kubernetes server
components
22
23. Copyright 2017 ITRI 工業技術研究院
Start Services
• Load Changed Units
• Start kubelet, and flannel
23
24. Copyright 2017 ITRI 工業技術研究院
Configure kubectl
• Download the kubectl Executable
• Configure kubectl
▪ Master server host
▪ Root CA public key
▪ Cluster admin public & private Keys
• Verify kubectl Configuration and Connection
kubectl get nodes
NAME LABELS STATUS
X.X.X.X kubernetes.io/hostname=X.X.X.X Ready
• Enabling shell autocompletion
echo "source <(kubectl completion bash)" >> ~/.bashrc
24
25. Copyright 2017 ITRI 工業技術研究院
Deploy the Add-ons
• DNS
• Dashboard
kubectl port-forward kubernetes-dashboard-xxxx 9090 --namespace=kube-
system
Then visit http://127.0.0.1:9090 in your browser.
25
27. Copyright 2017 ITRI 工業技術研究院
What’s MatchBox?
• HTTP and gRPC service that renders signed Ignition
configs, cloud-configs, network boot configs, and
metadata to machines to create CoreOS clusters
27
31. Copyright 2017 ITRI 工業技術研究院
Generate TLS Assets
./scripts/tls/k8s-certgen -h
Usage: k8s-certgen
Options:
-d DEST Destination for generated files (default: .examples/assets/tls)
-s SERVER Reachable Server IP for kubeconfig (e.g. node1.example.com)
-m MASTERS Controller Node Names/Addresses in SAN format
(e.g. IP.1=10.3.0.1,DNS.1=node1.example.com)
-w WORKERS Worker Node Names/Addresses in SAN format
(e.g. DNS.1=node2.example.com,DNS.2=node3.example.com)
-h Show help
31
38. Copyright 2017 ITRI 工業技術研究院
Conclusion
• Container Linux (CoreOS) is a good choice for bare
metal & production
• Manual installation vs. Matchbox+ignition
• What’s next?
▪ Try it
▪ Join Kubernetes Taiwan User Group
▪ Kubernetes Training Courses and Playground
a. https://www.katacoda.com/courses/kubernetes
b. https://www.katacoda.com/courses/kubernetes/playground
38