国产性生交xxxxx免费-国产中文字幕-啊灬啊灬啊灬快灬高潮了,亚洲国产午夜精品理论片在线播放 ,亚洲欧洲日本无在线码,色爽交视频免费观看

鍋爐信息網(wǎng) > 鍋爐知識 > 鍋爐百科

K8s 安裝

發(fā)布時間:

?環(huán)境初始化1:分別在2臺主機(jī)設(shè)置主機(jī)名稱hostnamectl set-hostname node1hostnamectl set-hostname node22:配置主機(jī)映射cat <<EO

?環(huán)境初始化

1:分別在2臺主機(jī)設(shè)置主機(jī)名稱

  1. hostnamectl set-hostname node1
  2. hostnamectl set-hostname node2


2:配置主機(jī)映射

  1. cat <<EOF > /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 192.168.124.129 node1
  5. 192.168.124.132 node2
  6. EOF


3:node1上執(zhí)行ssh免密碼登陸配置

  1. ssh-keygen #一路回車即可
  2. ssh-copy-id node2


4:兩臺主機(jī)配置、停防火墻、關(guān)閉Swap、關(guān)閉Selinux

  1. # 禁用防火墻:
  2. $ systemctl stop firewalld
  3. $ systemctl disable firewalld
  4. # 禁用SELINUX:
  5. $ setenforce 0
  6. $ cat /etc/selinux/config
  7. SELINUX=disabled
  8. # 創(chuàng)建/etc/sysctl.d/k8s.conf文件,添加如下內(nèi)容
  9. cat <<EOF > /etc/sysctl.d/k8s.conf
  10. net.bridge.bridge-nf-call-ip6tables = 1
  11. net.bridge.bridge-nf-call-iptables = 1
  12. EOF
  13. sysctl --system
  14. #關(guān)閉系統(tǒng)Swap
  15. swapoff -a
  16. sed -i 's/.*swap.*/#&/' /etc/fstab


鏡像準(zhǔn)備

如果你的節(jié)點(diǎn)上面有科學(xué)上網(wǎng)的工具,可以忽略這一步,我們需要提前將所需的http://gcr.io上面的鏡像下載到節(jié)點(diǎn)上面,當(dāng)然前提條件是你已經(jīng)成功安裝了docker。

1、master節(jié)點(diǎn),執(zhí)行下面的命令:

  1. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.12.0
  2. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.12.0
  3. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.0
  4. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.12.0
  5. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.2.24
  6. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.2.2
  7. docker pull cnych/flannel:v0.10.0-amd64
  8. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
  9. docker pull registry.cn-hangzhou.aliyuncs.com/k8sth/kubernetes-dashboard-amd64:v1.8.3
  10. docker pull registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-grafana-amd64:v4.4.3
  11. docker pull registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-influxdb-amd64:v1.3.3
  12. docker pull registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-amd64:3.1


  1. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.12.0 k8s.gcr.io/kube-apiserver:v1.12.0
  2. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.12.0
  3. docker tag
  4. registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.0 k8s.gcr.io/kube-proxy:v1.12.0
  5. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.12.0
  6. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
  7. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
  8. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2
  9. docker tag cnych/flannel:v0.10.0-amd64:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64


2、slave節(jié)點(diǎn),執(zhí)行下面的命令:

  1. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.0
  2. docker pull cnych/flannel:v0.10.0-amd64
  3. docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
  4. docker tag
  5. registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.0 k8s.gcr.io/kube-proxy:v1.12.0
  6. docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
  7. docker tag cnych/flannel:v0.10.0-amd64:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64


安裝配置kubernetes

兩個節(jié)點(diǎn)都需要安裝
安裝
  1. cat > /etc/yum.repos.d/kubernetes.repo <<EOF
  2. [kubernetes]
  3. name=Kubernetes
  4. baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
  5. enabled=1
  6. gpgcheck=0
  7. repo_gpgcheck=0
  8. EOF


我們是安裝最新版本的,所以直接yum install -y kubeadm即可,它會安裝相應(yīng)依賴包。

  1. 如果要指定版本,可以先看看有那些版本
  2. yum list kubeadm --showduplicates


配置 kubelet

修改文件kubelet的配置文件/etc/systemd/system/kubelet.service.d/10-kubeadm.conf, 配置文件中增加一項配置(在ExecStart之前):

  1. Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"


如圖所示:


  1. # kubelet設(shè)置開機(jī)自動運(yùn)行
  2. systemctl enable kubelet


啟動kubelet:

  1. systemctl start kubelet


集群安裝

  1. $ kubeadm init
  2. > --kubernetes-version=v1.12.0
  3. > --pod-network-cidr=10.244.0.0/16
  4. > --apiserver-advertise-address=192.168.124.129
  5. > --ignore-preflight-errors=Swap
  6. [init] using Kubernetes version: v1.12.0
  7. [preflight] running pre-flight checks
  8. [WARNING Swap]: running with swap on is not supported. Please disable swap
  9. [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 17.12.1-ce. Latest validated version: 18.06
  10. [preflight/images] Pulling images required for setting up a Kubernetes cluster
  11. [preflight/images] This might take a minute or two, depending on the speed of your internet connection
  12. [preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'
  13. [kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
  14. [kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
  15. [preflight] Activating the kubelet service
  16. [certificates] Generated etcd/ca certificate and key.
  17. [certificates] Generated etcd/server certificate and key.
  18. [certificates] etcd/server serving cert is signed for DNS names [node1 localhost] and IPs [127.0.0.1 ::1]
  19. [certificates] Generated etcd/peer certificate and key.
  20. [certificates] etcd/peer serving cert is signed for DNS names [node1 localhost] and IPs [192.168.124.129 127.0.0.1 ::1]
  21. [certificates] Generated apiserver-etcd-client certificate and key.
  22. [certificates] Generated etcd/healthcheck-client certificate and key.
  23. [certificates] Generated ca certificate and key.
  24. [certificates] Generated apiserver certificate and key.
  25. [certificates] apiserver serving cert is signed for DNS names [node1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.124.129]
  26. [certificates] Generated apiserver-kubelet-client certificate and key.
  27. [certificates] Generated front-proxy-ca certificate and key.
  28. [certificates] Generated front-proxy-client certificate and key.
  29. [certificates] valid certificates and keys now exist in "/etc/kubernetes/pki"
  30. [certificates] Generated sa key and public key.
  31. [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf"
  32. [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
  33. [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf"
  34. [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf"
  35. [controlplane] wrote Static Pod manifest for component kube-apiserver to "/etc/kubernetes/manifests/kube-apiserver.yaml"
  36. [controlplane] wrote Static Pod manifest for component kube-controller-manager to "/etc/kubernetes/manifests/kube-controller-manager.yaml"
  37. [controlplane] wrote Static Pod manifest for component kube-scheduler to "/etc/kubernetes/manifests/kube-scheduler.yaml"
  38. [etcd] Wrote Static Pod manifest for a local etcd instance to "/etc/kubernetes/manifests/etcd.yaml"
  39. [init] waiting for the kubelet to boot up the control plane as Static Pods from directory "/etc/kubernetes/manifests"
  40. [init] this might take a minute or longer if the control plane images have to be pulled
  41. [apiclient] All control plane components are healthy after 22.507741 seconds
  42. [uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
  43. [kubelet] Creating a ConfigMap "kubelet-config-1.12" in namespace kube-system with the configuration for the kubelets in the cluster
  44. [markmaster] Marking the node node1 as master by adding the label "node-role.kubernetes.io/master=''"
  45. [markmaster] Marking the node node1 as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]
  46. [patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "node1" as an annotation
  47. [bootstraptoken] using token: momf47.0scodcv3cm6t75vm
  48. [bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
  49. [bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
  50. [bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
  51. [bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace
  52. [addons] Applied essential addon: CoreDNS
  53. [addons] Applied essential addon: kube-proxy
  54. Your Kubernetes master has initialized successfully!
  55. To start using your cluster, you need to run the following as a regular user:
  56. mkdir -p $HOME/.kube
  57. sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  58. sudo chown $(id -u):$(id -g) $HOME/.kube/config
  59. You should now deploy a pod network to the cluster.
  60. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  61. https://kubernetes.io/docs/concepts/cluster-administration/addons/
  62. You can now join any number of machines by running the following on each node
  63. as root:
  64. kubeadm join 192.168.124.129:6443 --token momf47.0scodcv3cm6t75vm --discovery-token-ca-cert-hash sha256:cfeed429d671eeb39b8980ada10b55e79057cc65e108660ef86ae5043d6275f8


初始化主要過程為:

  • 1.kubeadm 執(zhí)行初始化前的檢查
  • 2.生成 token 和證書
  • 3.生成 KubeConfig 文件,kubelet 需要這個文件與 Master 通信。
  • 4.安裝 Master 組件,會從 goolge 的 Registry 下載組件的 Docker 鏡像,這一步可能會花一些時間,主要取決于網(wǎng)絡(luò)質(zhì)量,如果本地已有相關(guān)鏡像則會優(yōu)先使用本地的。
  • 5.安裝附加組件 kube-proxy 和 kube-dns
  • 6.Kubernetes Master 初始化成功
  • 7.提示后續(xù)操作

初始化失敗后處理辦法

  1. kubeadm reset


node1上面執(zhí)行如下命令

  1. mkdir -p $HOME/.kube
  2. sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  3. sudo chown $(id -u):$(id -g) $HOME/.kube/config


kubeadm生成證書密碼文件分發(fā)到node2上面去

  1. scp -r /etc/kubernetes/pki node03:/etc/kubernetes/


部署flannel網(wǎng)絡(luò),只需要在node1執(zhí)行就行

  1. $ wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
  2. $ kubectl apply -f kube-flannel.yml


  1. $ kubectl get node
  2. NAME STATUS ROLES AGE VERSION
  3. node1 Ready master 5m32s v1.12.2


安裝完成后使用kubectl get pods命令可以查看到我們集群中的組件運(yùn)行狀態(tài),如果都是Running狀態(tài)的話,那么恭喜你,你的master節(jié)點(diǎn)安裝成功了。

  1. kubectl get pods --all-namespaces
  2. NAMESPACE NAME READY STATUS RESTARTS AGE
  3. kube-system coredns-576cbf47c7-mntdb 1/1 Running 0 5m20s
  4. kube-system coredns-576cbf47c7-rswvv 1/1 Running 0 5m20s
  5. kube-system etcd-node1 1/1 Running 0 4m33s
  6. kube-system kube-apiserver-node1 1/1 Running 0 4m44s
  7. kube-system kube-controller-manager-node1 1/1 Running 0 4m28s
  8. kube-system kube-flannel-ds-amd64-gxqq8 1/1 Running 0 24s
  9. kube-system kube-proxy-4xgvb 1/1 Running 0 5m20s
  10. kube-system kube-scheduler-node1 1/1 Running 0 4m38s


部署Dashboard插件

kubernetes-dashboard.yaml文件內(nèi)容如下:

  1. # Copyright 2017 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Configuration to deploy release version of the Dashboard UI compatible with
  15. # Kubernetes 1.8.
  16. #
  17. # Example usage: kubectl create -f <this_file>
  18. # ------------------- Dashboard Secret ------------------- #
  19. apiVersion: v1
  20. kind: Secret
  21. metadata:
  22. labels:
  23. k8s-app: kubernetes-dashboard
  24. name: kubernetes-dashboard-certs
  25. namespace: kube-system
  26. type: Opaque
  27. ---
  28. # ------------------- Dashboard Service Account ------------------- #
  29. apiVersion: v1
  30. kind: ServiceAccount
  31. metadata:
  32. labels:
  33. k8s-app: kubernetes-dashboard
  34. name: kubernetes-dashboard
  35. namespace: kube-system
  36. ---
  37. # ------------------- Dashboard Role & Role Binding ------------------- #
  38. kind: Role
  39. apiVersion: rbac.authorization.k8s.io/v1
  40. metadata:
  41. name: kubernetes-dashboard-minimal
  42. namespace: kube-system
  43. rules:
  44. # Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret.
  45. - apiGroups: [""]
  46. resources: ["secrets"]
  47. verbs: ["create"]
  48. # Allow Dashboard to create 'kubernetes-dashboard-settings' config map.
  49. - apiGroups: [""]
  50. resources: ["configmaps"]
  51. verbs: ["create"]
  52. # Allow Dashboard to get, update and delete Dashboard exclusive secrets.
  53. - apiGroups: [""]
  54. resources: ["secrets"]
  55. resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs"]
  56. verbs: ["get", "update", "delete"]
  57. # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.
  58. - apiGroups: [""]
  59. resources: ["configmaps"]
  60. resourceNames: ["kubernetes-dashboard-settings"]
  61. verbs: ["get", "update"]
  62. # Allow Dashboard to get metrics from heapster.
  63. - apiGroups: [""]
  64. resources: ["services"]
  65. resourceNames: ["heapster"]
  66. verbs: ["proxy"]
  67. - apiGroups: [""]
  68. resources: ["services/proxy"]
  69. resourceNames: ["heapster", "http:heapster:", "https:heapster:"]
  70. verbs: ["get"]
  71. ---
  72. apiVersion: rbac.authorization.k8s.io/v1
  73. kind: RoleBinding
  74. metadata:
  75. name: kubernetes-dashboard-minimal
  76. namespace: kube-system
  77. roleRef:
  78. apiGroup: rbac.authorization.k8s.io
  79. kind: Role
  80. name: kubernetes-dashboard-minimal
  81. subjects:
  82. - kind: ServiceAccount
  83. name: kubernetes-dashboard
  84. namespace: kube-system
  85. ---
  86. # ------------------- Dashboard Deployment ------------------- #
  87. kind: Deployment
  88. apiVersion: apps/v1beta2
  89. metadata:
  90. labels:
  91. k8s-app: kubernetes-dashboard
  92. name: kubernetes-dashboard
  93. namespace: kube-system
  94. spec:
  95. replicas: 1
  96. revisionHistoryLimit: 10
  97. selector:
  98. matchLabels:
  99. k8s-app: kubernetes-dashboard
  100. template:
  101. metadata:
  102. labels:
  103. k8s-app: kubernetes-dashboard
  104. spec:
  105. nodeSelector:
  106. node-role.kubernetes.io/master: ""
  107. containers:
  108. - name: kubernetes-dashboard
  109. image: registry.cn-hangzhou.aliyuncs.com/k8sth/kubernetes-dashboard-amd64:v1.8.3
  110. ports:
  111. - containerPort: 8443
  112. protocol: TCP
  113. args:
  114. - --auto-generate-certificates
  115. # Uncomment the following line to manually specify Kubernetes API server Host
  116. # If not specified, Dashboard will attempt to auto discover the API server and connect
  117. # to it. Uncomment only if the default does not work.
  118. # - --apiserver-host=http://my-address:port
  119. volumeMounts:
  120. - name: kubernetes-dashboard-certs
  121. mountPath: /certs
  122. # Create on-disk volume to store exec logs
  123. - mountPath: /tmp
  124. name: tmp-volume
  125. livenessProbe:
  126. httpGet:
  127. scheme: HTTPS
  128. path: /
  129. port: 8443
  130. initialDelaySeconds: 30
  131. timeoutSeconds: 30
  132. volumes:
  133. - name: kubernetes-dashboard-certs
  134. secret:
  135. secretName: kubernetes-dashboard-certs
  136. - name: tmp-volume
  137. emptyDir: {}
  138. serviceAccountName: kubernetes-dashboard
  139. # Comment the following tolerations if Dashboard must not be deployed on master
  140. tolerations:
  141. - key: node-role.kubernetes.io/master
  142. effect: NoSchedule
  143. ---
  144. # ------------------- Dashboard Service ------------------- #
  145. kind: Service
  146. apiVersion: v1
  147. metadata:
  148. labels:
  149. k8s-app: kubernetes-dashboard
  150. name: kubernetes-dashboard
  151. namespace: kube-system
  152. spec:
  153. type: NodePort
  154. ports:
  155. - port: 443
  156. targetPort: 8443
  157. nodePort: 30000
  158. selector:
  159. k8s-app: kubernetes-dashboard
  160. ---
  161. apiVersion: v1
  162. kind: ServiceAccount
  163. metadata:
  164. name: admin-user
  165. namespace: kube-system
  166. ---
  167. apiVersion: rbac.authorization.k8s.io/v1beta1
  168. kind: ClusterRoleBinding
  169. metadata:
  170. name: admin-user
  171. roleRef:
  172. apiGroup: rbac.authorization.k8s.io
  173. kind: ClusterRole
  174. name: cluster-admin
  175. subjects:
  176. - kind: ServiceAccount
  177. name: admin-user
  178. namespace: kube-system


執(zhí)行如下文件

  1. kubectl create -f kubernetes-dashboard.yaml


獲取token,通過令牌登陸

  1. $ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
  2. Name: admin-user-token-z6lhq
  3. Namespace: kube-system
  4. Labels: <none>
  5. Annotations: kubernetes.io/service-account.name: admin-user
  6. kubernetes.io/service-account.uid: 1b1a9541-ed6d-11e8-8458-000c2960d34d
  7. Type: kubernetes.io/service-account-token
  8. Data
  9. ====
  10. ca.crt: 1025 bytes
  11. namespace: 11 bytes
  12. token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXo2bGhxIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIxYjFhOTU0MS1lZDZkLTExZTgtODQ1OC0wMDBjMjk2MGQzNGQiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.sdAwrS-tLEHY62ufIwZBrC58-yVsqMGV_AdeyFu8EBPpzdSfgCDemPIyEonGdz9cU6CLMpLnvJ4r7OLBexCaZ4WPIh_Q6N3YjK150d--3uzxQVxtoezVrrgBUCAUgC1KNewa0Suu32A-c-tPj2ykxSGpIYVDDQDQKqw_2E91diF-WKD9YMTl2H9sQU6N9RvSW7t0kQKcBFe8mDTUl4jrT-LnaISL_Qxcn0gwTlU-cbTBYuTpKvyLJ-aa6DfmFebQWA_Je-CLwh6ayk1X6DVVaSE_H5S9atGvnLQ1QVuj3ukHRtKnNSzAGM-boBaGTWZ0Khxo3sbsi7kvUZArYV1Vow


通過firefox訪問dashboard,輸入token,即可登陸

  1. https://192.168.124.129:30000/#!/login


安裝heapster

  1. $ kubectl create -f kube-heapster/influxdb/
  2. $ kubectl create -f kube-heapster/rbac/


heapster文件信息:

  1. [root@node01 ~]# tree kube-heapster/
  2. kube-heapster/
  3. ├── influxdb
  4. ├── grafana.yaml
  5. ├── heapster.yaml
  6. └── influxdb.yaml
  7. └── rbac
  8. └── heapster-rbac.yaml


grafana.yaml

  1. apiVersion: extensions/v1beta1
  2. kind: Deployment
  3. metadata:
  4. name: monitoring-grafana
  5. namespace: kube-system
  6. spec:
  7. replicas: 1
  8. template:
  9. metadata:
  10. labels:
  11. task: monitoring
  12. k8s-app: grafana
  13. spec:
  14. nodeSelector:
  15. node-role.kubernetes.io/master: ""
  16. containers:
  17. - name: grafana
  18. image: registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-grafana-amd64:v4.4.3
  19. imagePullPolicy: IfNotPresent
  20. ports:
  21. - containerPort: 3000
  22. protocol: TCP
  23. volumeMounts:
  24. - mountPath: /etc/ssl/certs
  25. name: ca-certificates
  26. readOnly: true
  27. - mountPath: /var
  28. name: grafana-storage
  29. env:
  30. - name: INFLUXDB_HOST
  31. value: monitoring-influxdb
  32. - name: GF_SERVER_HTTP_PORT
  33. value: "3000"
  34. # The following env variables are required to make Grafana accessible via
  35. # the kubernetes api-server proxy. On production clusters, we recommend
  36. # removing these env variables, setup auth for grafana, and expose the grafana
  37. # service using a LoadBalancer or a public IP.
  38. - name: GF_AUTH_BASIC_ENABLED
  39. value: "false"
  40. - name: GF_AUTH_ANONYMOUS_ENABLED
  41. value: "true"
  42. - name: GF_AUTH_ANONYMOUS_ORG_ROLE
  43. value: Admin
  44. - name: GF_SERVER_ROOT_URL
  45. # If you're only using the API Server proxy, set this value instead:
  46. # value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
  47. value: /
  48. volumes:
  49. - name: ca-certificates
  50. hostPath:
  51. path: /etc/ssl/certs
  52. - name: grafana-storage
  53. emptyDir: {}
  54. ---
  55. apiVersion: v1
  56. kind: Service
  57. metadata:
  58. labels:
  59. # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
  60. # If you are NOT using this as an addon, you should comment out this line.
  61. kubernetes.io/cluster-service: 'true'
  62. kubernetes.io/name: monitoring-grafana
  63. name: monitoring-grafana
  64. namespace: kube-system
  65. spec:
  66. # In a production setup, we recommend accessing Grafana through an external Loadbalancer
  67. # or through a public IP.
  68. # type: LoadBalancer
  69. # You could also use NodePort to expose the service at a randomly-generated port
  70. # type: NodePort
  71. ports:
  72. - port: 80
  73. targetPort: 3000
  74. selector:
  75. k8s-app: grafana


heapster.yaml

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: heapster
  5. namespace: kube-system
  6. ---
  7. apiVersion: extensions/v1beta1
  8. kind: Deployment
  9. metadata:
  10. name: heapster
  11. namespace: kube-system
  12. spec:
  13. replicas: 1
  14. template:
  15. metadata:
  16. labels:
  17. task: monitoring
  18. k8s-app: heapster
  19. spec:
  20. serviceAccountName: heapster
  21. nodeSelector:
  22. node-role.kubernetes.io/master: ""
  23. containers:
  24. - name: heapster
  25. image: registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-amd64:v1.4.2
  26. imagePullPolicy: IfNotPresent
  27. command:
  28. - /heapster
  29. - --source=kubernetes:https://kubernetes.default
  30. - --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086
  31. ---
  32. apiVersion: v1
  33. kind: Service
  34. metadata:
  35. labels:
  36. task: monitoring
  37. # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
  38. # If you are NOT using this as an addon, you should comment out this line.
  39. kubernetes.io/cluster-service: 'true'
  40. kubernetes.io/name: Heapster
  41. name: heapster
  42. namespace: kube-system
  43. spec:
  44. ports:
  45. - port: 80
  46. targetPort: 8082
  47. selector:
  48. k8s-app: heapster


influxdb.yaml

  1. apiVersion: extensions/v1beta1
  2. kind: Deployment
  3. metadata:
  4. name: monitoring-influxdb
  5. namespace: kube-system
  6. spec:
  7. replicas: 1
  8. template:
  9. metadata:
  10. labels:
  11. task: monitoring
  12. k8s-app: influxdb
  13. spec:
  14. nodeSelector:
  15. node-role.kubernetes.io/master: ""
  16. containers:
  17. - name: influxdb
  18. image: registry.cn-hangzhou.aliyuncs.com/k8sth/heapster-influxdb-amd64:v1.3.3
  19. imagePullPolicy: IfNotPresent
  20. volumeMounts:
  21. - mountPath: /data
  22. name: influxdb-storage
  23. volumes:
  24. - name: influxdb-storage
  25. emptyDir: {}
  26. ---
  27. apiVersion: v1
  28. kind: Service
  29. metadata:
  30. labels:
  31. task: monitoring
  32. # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
  33. # If you are NOT using this as an addon, you should comment out this line.
  34. kubernetes.io/cluster-service: 'true'
  35. kubernetes.io/name: monitoring-influxdb
  36. name: monitoring-influxdb
  37. namespace: kube-system
  38. spec:
  39. ports:
  40. - port: 8086
  41. targetPort: 8086
  42. selector:
  43. k8s-app: influxdb


heapster-rbac.yaml

  1. kind: ClusterRoleBinding
  2. apiVersion: rbac.authorization.k8s.io/v1beta1
  3. metadata:
  4. name: heapster
  5. roleRef:
  6. apiGroup: rbac.authorization.k8s.io
  7. kind: ClusterRole
  8. name: system:heapster
  9. subjects:
  10. - kind: ServiceAccount
  11. name: heapster
  12. namespace: kube-system


讓master也運(yùn)行pod(默認(rèn)master不運(yùn)行pod)

  1. kubectl taint nodes --all node-role.kubernetes.io/master-


添加node2節(jié)點(diǎn)到集群

在node2節(jié)點(diǎn)執(zhí)行如下命令,即可將節(jié)點(diǎn)添加進(jìn)集群

  1. kubeadm join 192.168.124.129:6443 --token momf47.0scodcv3cm6t75vm --discovery-token-ca-cert-hash sha256:cfeed429d671eeb39b8980ada10b55e79057cc65e108660ef86ae5043d6275f8 --ignore-preflight-errors=Swap
  2. [preflight] running pre-flight checks
  3. [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]
  4. you can solve this problem with following methods:
  5. 1. Run 'modprobe -- ' to load missing kernel modules;
  6. 2. Provide the missing builtin kernel ipvs support
  7. [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 17.12.1-ce. Latest validated version: 18.06
  8. [discovery] Trying to connect to API Server "192.168.124.129:6443"
  9. [discovery] Created cluster-info discovery client, requesting info from "https://192.168.124.129:6443"
  10. [discovery] Requesting info from "https://192.168.124.129:6443" again to validate TLS against the pinned public key
  11. [discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.124.129:6443"
  12. [discovery] Successfully established connection with API Server "192.168.124.129:6443"
  13. [kubelet] Downloading configuration for the kubelet from the "kubelet-config-1.12" ConfigMap in the kube-system namespace
  14. [kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
  15. [kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
  16. [preflight] Activating the kubelet service
  17. [tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...
  18. [patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "node2" as an annotation
  19. This node has joined the cluster:
  20. * Certificate signing request was sent to apiserver and a response was received.
  21. * The Kubelet was informed of the new secure connection details.
  22. Run 'kubectl get nodes' on the master to see this node join the cluster.


  1. $ kubectl get node
  2. NAME STATUS ROLES AGE VERSION
  3. node1 Ready master 78m v1.12.2
  4. node2 Ready <none> 64m v1.12.2


  1. $ kubectl get pods --all-namespaces
  2. NAMESPACE NAME READY STATUS RESTARTS AGE
  3. kube-system coredns-576cbf47c7-mntdb 1/1 Running 0 20m
  4. kube-system coredns-576cbf47c7-rswvv 1/1 Running 0 20m
  5. kube-system etcd-node1 1/1 Running 0 19m
  6. kube-system heapster-6955774cc5-gt4c8 1/1 Running 0 13m
  7. kube-system kube-apiserver-node1 1/1 Running 0 20m
  8. kube-system kube-controller-manager-node1 1/1 Running 0 19m
  9. kube-system kube-flannel-ds-amd64-2qzpw 1/1 Running 0 6m55s
  10. kube-system kube-flannel-ds-amd64-gxqq8 1/1 Running 0 15m
  11. kube-system kube-proxy-4xgvb 1/1 Running 0 20m
  12. kube-system kube-proxy-xhvfn 1/1 Running 0 6m55s
  13. kube-system kube-scheduler-node1 1/1 Running 0 20m
  14. kube-system kubernetes-dashboard-55f88765fb-qvm9w 1/1 Running 0 15m
  15. kube-system monitoring-grafana-9658ddc99-k8np4 1/1 Running 0 13m
  16. kube-system monitoring-influxdb-96bf68f65-9mn86 1/1 Running 0 13m


訪問dashboard




上一篇:SAS SDS

下一篇:SDS計劃

精選推薦

  • 711關(guān)東煮供應(yīng)商
    711關(guān)東煮供應(yīng)商

    今天給大家介紹三位,奶粉,全家、羅森這些便利店里關(guān)東煮的供應(yīng)商。店里賣三四塊錢一串的關(guān)東煮,在網(wǎng)上買不到,一塊錢就搞定。首先關(guān)東

  • 健康日歷|高壓鍋容易爆炸的4個原因
    健康日歷|高壓鍋容易爆炸的4個原因

    來源:醫(yī)藥養(yǎng)生保健報設(shè)計:李雅琴醫(yī)學(xué)審核:姜峰出品人:胡麗麗

  • 高爐
    高爐

    今天這活卻是個白事,等到了時辰,那家人便準(zhǔn)備火化,本來準(zhǔn)備送普爐,我卻心中一動,便對那家人說道:“這老人走也不要省,還是送高爐吧。”

  • 高壓鍋和電壓力鍋的區(qū)別,推薦幾款點(diǎn)壓力鍋
    高壓鍋和電壓力鍋的區(qū)別,推薦幾款點(diǎn)壓

    記得之前有一次去朋友家玩,他正在用高壓鍋煮小米粥,是的,高壓鍋壓小米粥,大概煮了半小時,高壓鍋突然爆炸了,現(xiàn)場慘不忍睹啊,幸好廚房里沒

0