k8s 虛擬機器內安裝
https://blog.csdn.net/watermelonbig/article/details/79341644
以下實驗均是使用CentOS7.4 Minimual版本系統完成。用vagrant建立虛擬機器
1、關閉系統防火牆
systemctl disable firewalld
systemctl stop firewalld
2、安裝etcd和Kubernetes軟體
yum -y install etcd kubernetes
3、按順序啟動所有的服務
systemctl start etcd && systemctl start docker && systemctl start kube-apiserver && systemctl start kube-controller-manager && systemctl start kube-scheduler && systemctl start kubelet && systemctl start kube-proxy
一個單機版的kubernete就安裝完成了。
systemctl restart etcd && systemctl restart docker && systemctl restartkube-apiserver && systemctl restart kube-controller-manager && systemctl restart kube-scheduler && systemctl restartkubelet && systemctl restart kube-proxy
systemctl start etcd docker kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy
4、建立和啟動一個MySQL服務
(1)定義一個RC檔案:mysql-rc.yaml
apiVersion: v1
kind: ReplicationController #型別為副本控制器RC
metadata:
name: mysql #RC的名稱,全域性唯一
spec:
replicas: 1 #POD副本期待數量kubectl get rc
selector:
app: mysql #符合目標的Pod擁有此標籤
template: #根據此模板建立Pod的副本
metadata:
labels:
app: mysql #Pod副本擁有的標籤,對應RC的Selector
spec:
containers: #Pod內容器的定義部分
- name: mysql #容器的名稱
image: mysql #容器對應的Docker Image
ports:
- containerPort: 3306 #容器應用監聽的埠號
env: #注入容器內的環境變數
- name: MYSQL_ROOT_PASSWORD
value: "123456"
在Master節點執行建立命令:
# kubectl create -f mysql-rc.yaml
replicationcontroller "mysql" created
檢視剛剛建立的RC:
# kubectl get rc
NAME DESIRED CURRENT READY AGE
mysql 1 0 0 26s
檢視Pod的建立情況:
# kubectl get pods
NAME READY STATUS RESTARTS AGE