Kubernetes安装
本文使用vultr虚拟主机实现
邀请注册链接:http://www.vultr.com/?ref=6940267
ETCD集群安装:http://crabdave.iteye.com/blog/2365488
配置docker 和 flannel:http://crabdave.iteye.com/blog/2365490
download kubernetes
kubernetes v1.3.0 大约1.4G 使用东京的vultr实例下载很快
wget https://github.com/kubernetes/kubernetes/releases/download/v1.3.0/kubernetes.tar.gz
tar -xvf kubernetes.tar.gz
cd kubernetes/server
将kubernetes-server-linux-amd64.tar.gz解压
-rw-r--r-- 1 root root 352M 7月 1 2016 kubernetes-server-linux-amd64.tar.gz
tar -xvf kubernetes-server-linux-amd64.tar.gz
cd /root/kubernetes/server/kubernetes/server/bin
find ./ -perm 755 | xargs -i cp {} /usr/bin
其它两台机器拷贝kubernetes到本机
scp root@10.99.0.10:/root/kubernetes/server/kubernetes-server-linux-amd64.tar.gz ./
tar -xvf kubernetes-server-linux-amd64.tar.gz
cd /root/kubernetes/server/bin
cp kube-proxy /usr/bin
cp kubelet /usr/bin
---------------------------------
mkdir -p /opt/kubernetes/
cat <<EOF >/lib/systemd/system/kube-apiserver.service
[Unit]
Description=kube-apiserver
[Service]
EnvironmentFile=/etc/sysconfig/kube-apiserver
ExecStart=/usr/bin/kube-apiserver \$ETCD_SERVERS \\
\$LOG_DIR \\
\$SERVICE_CLUSTER_IP_RANGE \\
\$INSECURE_BIND_ADDRESS \\
\$INSECURE_PORT \\
\$BIND_ADDRESS \\
\$SECURE_PORT \\
\$AUTHORIZATION_MODE \\
\$AUTHORIZATION_FILE \\
\$BASIC_AUTH_FILE \\
\$KUBE_APISERVER_OPTS
Restart=on-failure
EOF
cat /lib/systemd/system/kube-apiserver.service
---------------------------------
cat <<EOF >/etc/sysconfig/kube-apiserver
# configure file for kube-apiserver
# --etcd-servers
ETCD_SERVERS='--etcd-servers=http://10.99.0.10:2380,http://10.99.0.11:2380,http://10.99.0.12:2380'
# --log-dir
LOG_DIR='/opt/kubernetes/logs'
# --service-cluster-ip-range
SERVICE_CLUSTER_IP_RANGE='--service-cluster-ip-range=172.16.0.0/16'
# --insecure-bind-address
INSECURE_BIND_ADDRESS='--insecure-bind-address=0.0.0.0'
# --insecure-port
INSECURE_PORT='--insecure-port=8080'
# --bind-address
BIND_ADDRESS='--bind-address=0.0.0.0'
# --secure-port
SECURE_PORT='--secure-port=6443'
# --authorization-mode
AUTHORIZATION_MODE='--authorization-mode=ABAC'
# --authorization-policy-file
AUTHORIZATION_FILE='--authorization-policy-file=/opt/kubernetes/authorization'
# --basic-auth-file
BASIC_AUTH_FILE='--basic-auth-file=/opt/kubernetes/authentication.csv'
# other parameters
KUBE_APISERVER_OPTS=''
EOF
cat /etc/sysconfig/kube-apiserver
---------------------------------
echo '{"user": "admin"}'>/opt/kubernetes/authorization
(密码,用户名,用户ID):
echo "admin,admin,adminID" > /opt/kubernetes/authentication.csv
---------------------------------
启动kube-apiserver
systemctl daemon-reload
systemctl start kube-apiserver
systemctl status -l kube-apiserver
curl -L http://10.99.0.10:8080/healthz
tail -n 1000 /var/log/messages
----------------
启动失败,查看日志
tail -n 1000 /var/log/messages
出现异常
/lib/lsb/init-functions no such file or directory
需要安装
yum install -y redhat-lsb
还可以通过如下命令查看kube-apiserver是否正常,正常则返回'ok':
curl -L http://10.99.0.10:8080/healthz
------------------------------------------------------------------
创建、配置和启动kube-controller-manager服务
三个组件启动是有顺序,必须等kube-apiserver正常启动之后再启动kube-controller-manager。
cat <<EOF >/etc/sysconfig/kube-controller
# configure file for kube-controller-manager
# --master
KUBE_MASTER='--master=http://10.99.0.10:8080'
# --log-dir
LOG_DIR='--log-dir=/opt/kubernetes/logs'
# --cloud-provider
CLOUD_PROVIDER='--cloud-provider='
# other parameters
KUBE_CONTROLLER_OPTS=''
EOF
cat /etc/sysconfig/kube-controller
---------------
cat <<EOF >/lib/systemd/system/kube-controller.service
[Unit]
Description=kube-controller-manager
After=kube-apiserver.service
Wants=kube-apiserver.service
[Service]
EnvironmentFile=/etc/sysconfig/kube-controller
ExecStart=/usr/bin/kube-controller-manager \$KUBE_MASTER \\
\$LOG_DIR \\
\$CLOUD_PROVIDER \\
\$KUBE_CONTROLLER_OPTS
Restart=on-failure
EOF
cat /lib/systemd/system/kube-controller.service
---------------
启动kube-controller-manager
systemctl daemon-reload
systemctl start kube-controller
systemctl status -l kube-controller
------------------------------------------------------------------
创建、配置和启动kube-scheduler服务
cat <<EOF >/etc/sysconfig/kube-scheduler
# configure file for kube-scheduler
# --master
KUBE_MASTER='--master=http://10.99.0.10:8080'
# --log-dir
LOG_DIR='--log-dir=/opt/kubernetes/logs'
# other parameters
KUBE_SCHEDULER_OPTS=''
EOF
cat /etc/sysconfig/kube-scheduler
-----------------
cat <<EOF >/lib/systemd/system/kube-scheduler.service
[Unit]
Description=kube-scheduler
After=kube-apiserver.service
Wants=kube-apiserver.service
[Service]
EnvironmentFile=/etc/sysconfig/kube-scheduler
ExecStart=/usr/bin/kube-scheduler \$KUBE_MASTER \\
\$LOG_DIR \\
\$KUBE_SCHEDULER_OPTS
Restart=on-failure
EOF
cat /lib/systemd/system/kube-scheduler.service
------------
启动kube-scheduler
systemctl daemon-reload
systemctl start kube-scheduler
systemctl status -l kube-scheduler
------------------------------------------------------------------
启动k8s-node端,开始配置两台节点机器
mkdir -p /opt/kubernetes/
--------------------------
配置和启动kube-proxy(三台机器,master api server重启一下)
cat <<EOF >/etc/sysconfig/kube-proxy
# configure file for kube-proxy
# --master
KUBE_MASTER='--master=http://10.99.0.10:8080'
# --proxy-mode
PROXY_MODE='--proxy-mode=iptables'
# --log-dir
LOG_DIR='--log-dir=/opt/kubernetes/logs'
# other parameters
KUBE_PROXY_OPTS=''" > /etc/sysconfig/kube-proxy
EOF
cat /etc/sysconfig/kube-proxy
--------------------------
cat <<EOF >/lib/systemd/system/kube-proxy.service
[Unit]
Description=kube-proxy
[Service]
EnvironmentFile=/etc/sysconfig/kube-proxy
ExecStart=/usr/bin/kube-proxy \$KUBE_MASTER \\
\$PROXY_MODE \\
\$LOG_DIR \\
\$KUBE_PROXY_OPTS
Restart=on-failure
EOF
cat /usr/lib/systemd/system/kube-proxy.service
启动kube-proxy
systemctl daemon-reload
systemctl start kube-proxy
systemctl status -l kube-proxy
------------------------------------------------------------------
配置和启动kubelet
cat <<EOF >/lib/systemd/system/kubelet.service
[Unit]
Description=kubelet
[Service]
EnvironmentFile=/etc/sysconfig/kubelet
ExecStart=/usr/bin/kubelet \$API_SERVERS \\
\$ADDRESS \\
\$HOSTNAME_OVERRIDE \\
\$ALLOW_PRIVILEGED \\
\$POD_INFRA \\
\$CLUSTER_DNS \\
\$CLUSTER_DOMAIN \\
\$MAX_PODS \\
\$LOG_DIR \\
\$KUBELET_OPTS
Restart=on-failure
EOF
cat /lib/systemd/system/kubelet.service
-------------------------------
/etc/sysconfig/kubelet配置10.99.0.11机器
cat <<EOF >/etc/sysconfig/kubelet
# configure file for kubelet
# --api-servers
API_SERVERS='--api-servers=http://10.99.0.10:8080'
# --address
ADDRESS='--address=0.0.0.0'
# --hostname-override
HOSTNAME_OVERRIDE='vultr.guest-11'
# --allow-privileged
ALLOW_PRIVILEGED='--allow-privileged=false'
# --pod-infra-container-image
#POD_INFRA='--pod-infra-container-image=10.23.23.76:5000/kubernetes/pause:latest'
# --cluster-dns
#CLUSTER_DNS='--cluster-dns=172.16.66.66'
# --cluster-domain
#CLUSTER_DOMAIN='--cluster-domain=cluster.local'
# --max-pods
MAX_PODS='--max-pods=70'
# --log-dir
LOG_DIR='--log-dir=/opt/kubernetes/logs'
# other parameters
KUBELET_OPTS=''
EOF
cat /etc/sysconfig/kubelet
--------------
/etc/sysconfig/kubelet配置10.99.0.12机器
cat <<EOF >/etc/sysconfig/kubelet
echo "# configure file for kubelet
# --api-servers
API_SERVERS='--api-servers=http://10.99.0.10:8080'
# --address
ADDRESS='--address=0.0.0.0'
# --hostname-override
HOSTNAME_OVERRIDE='vultr.guest-12'
# --allow-privileged
ALLOW_PRIVILEGED='--allow-privileged=false'
# --pod-infra-container-image
#POD_INFRA='--pod-infra-container-image=10.23.150.76:5000/kubernetes/pause:latest'
# --cluster-dns
#CLUSTER_DNS='--cluster-dns=172.16.66.66'
# --cluster-domain
#CLUSTER_DOMAIN='--cluster-domain=cluster.local'
# --max-pods
MAX_PODS='--max-pods=70'
# --log-dir
LOG_DIR='--log-dir=/opt/kubernetes/logs'
# other parameters
KUBELET_OPTS=''
EOF
cat /etc/sysconfig/kubelet
--------------
启动kubelet
systemctl daemon-reload
systemctl start kubelet
systemctl status -l kubelet
------------------------------------------------------------------
回到master机器 10.99.0.10
kubectl --server=10.99.0.10:8080 get nodes
NAME STATUS AGE
vultr.guest-11 Ready 6m
vultr.guest-12 Ready 7m
------------------------------------------------------------------
mkdir -p ~/workspace
cd ~/workspace
echo " apiVersion: v1
kind: ReplicationController
metadata:
name: test-1
spec:
replicas: 1
template:
metadata:
labels:
app: test-1
spec:
containers:
- name: nginx-1
image: docker.io/nginx
nodeSelector:
kubernetes.io/hostname: vultr.guest-11" > test-1.yaml
cat test-1.yaml
echo " apiVersion: v1
kind: ReplicationController
metadata:
name: test-2
spec:
replicas: 1
template:
metadata:
labels:
app: test-2
spec:
containers:
- name: nginx-2
image: docker.io/nginx
nodeSelector:
kubernetes.io/hostname: vultr.guest-11" > test-2.yaml
cat test-2.yaml
echo " apiVersion: v1
kind: ReplicationController
metadata:
name: test-3
spec:
replicas: 1
template:
metadata:
labels:
app: test-3
spec:
containers:
- name: nginx-3
image: docker.io/nginx
nodeSelector:
kubernetes.io/hostname: vultr.guest-12" > test-3.yaml
cat test-3.yaml
echo " apiVersion: v1
kind: ReplicationController
metadata:
name: test-4
spec:
replicas: 1
template:
metadata:
labels:
app: test-4
spec:
containers:
- name: nginx-4
image: docker.io/nginx
nodeSelector:
kubernetes.io/hostname: vultr.guest-12" > test-4.yaml
cat test-4.yaml
------------------------------------------------------------------
kubectl --server=10.99.0.10:8080 create -f test-1.yaml
kubectl --server=10.99.0.10:8080 create -f test-2.yaml
kubectl --server=10.99.0.10:8080 create -f test-3.yaml
kubectl --server=10.99.0.10:8080 create -f test-4.yaml
kubectl --server=10.99.0.10:8080 get pods
NAME READY STATUS RESTARTS AGE
test-1-p4te6 1/1 Running 0 35s
test-2-7lvz6 1/1 Running 0 34s
test-3-21o5n 1/1 Running 0 34s
test-4-tfkkz 1/1 Running 0 34s
查看IP地址及其它相关信息
kubectl --server=10.99.0.10:8080 describe pod test-1-p4te6
kubectl --server=10.99.0.10:8080 describe pod test-2-7lvz6
kubectl --server=10.99.0.10:8080 describe pod test-3-21o5n
kubectl --server=10.99.0.10:8080 describe pod test-4-tfkkz
------------------------------------------------------------------
相关推荐
k8s安装部署,k8s教程:Kubernetes 安装部署教程+编程知识+技术开发; k8s安装部署,k8s教程:Kubernetes 安装部署教程+编程知识+技术开发; k8s安装部署,k8s教程:Kubernetes 安装部署教程+编程知识+技术开发; k8...
适合新手部署实验
【Kubernetes安装脚本】 Kubernetes(简称K8s)是一种流行的开源容器编排系统,用于自动化容器化应用的部署、扩展和管理。它提供了一种高效、灵活的方式来管理跨多个主机的容器化应用程序。在CentOS 7操作系统上...
一步一步安装kubernetes, 步骤比较详细, 适合新手
基于CentOS 7的Kubernetes安装全过程(含附件) 目录如下: 第一部分:Nginx on Kubernetes应用部署 3 一、环境准备 3 1.1软硬件环境 3 1.2 网络拓扑 4 二、Kubenetes及相关组件部署 6 2.1 Docker容器及私有仓库部署...
Kubernetes安装 Kubernetes是一种开源的容器编排系统,它可以自动化部署、扩展和管理容器ized应用程序。Kubernetes提供了一个高度灵活和可扩展的平台,使得开发者可以快速构建、部署和管理复杂的应用程序。 ...
### Kubernetes离线集群二进制安装知识点解析 #### 一、环境准备与基础软件安装 在搭建Kubernetes(K8s)集群之前,首先需要确保所有节点的基础环境一致且已安装必要的工具。 **安装基础工具:** ```bash yum ...
这个文档是学习和实践Kubernetes安装部署的重要参考资料,务必仔细阅读和实践其中的教程。 总的来说,Kubernetes提供了一种强大且灵活的方式来管理容器化应用,但其安装和部署过程可能较为复杂,需要一定的学习和...
在了解了以上关于Kubernetes安装部署手册的知识点后,我们可以清楚地看到Kubernetes在容器化技术领域的影响力和其强大的功能。通过这份手册,运维人员和开发者可以学习到如何有效地部署、管理、扩展和维护Kubernetes...
在“kubernetes安装相关包”中,"pkg"可能指的是安装过程中的软件包或者源代码包。这些包通常包括上述组件的二进制文件、配置文件、依赖库等。安装Kubernetes涉及的步骤可能包括以下部分: 1. **环境准备**:确保...
Kubernetes指南+Kubernetes安装全流程,让你彻底学会Kubernetes
此文介绍通过kubernetes安装redmine。 详细介绍请参考博客文章:https://mp.csdn.net/postedit/82082134 此文档为excel格式,保护操作步骤的大部分截图,方便学习。 主要包括以下内容: 从github取得redmine的yaml...
- **Kubernetes**的名字来自希腊语,意思是“舵手” 或 “领航员”。K8s是将8个字母“ubernete”替换为“8”的缩写。 - K8S的创造者,是众人皆知的行业巨头——**Google**。 - 然而K8S并不是一件全新的发明。它的...
k8s集群软件包,版本是v1.15.1
Kubernetes安装部署.docx
kubernetes 安装程序 arm64 架构 Kubernetes版本 v1.25.15 不包含kube容器镜像,仅安装工具和附属配套工具链 包含以下工具: apiextensions-apiserver kube-aggregator kube-apiserver kube-controller-manager kube-...
kubernetes安装配置详解,docker配置,路由配置,k8s的监控实例配置以及nginx实例配置等等。下载app注册免费获取:http://m3w.cn/jcsh
Rancher Labs推出的Rancher RKE是一款基于Go语言开发的开源工具,它的设计目标是提供一个轻量级、安全且易于使用的Kubernetes安装程序。RKE的亮点在于其极简的命令行界面,使得用户只需几行命令,即可完成Kubernetes...