# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
# master
yum -y install etcd kubernetes-master
vi /etc/etcd/etcd.conf
#ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
vi /etc/kubernetes/apiserver
#KUBE_API_ADDRESS="--insecure-bind-address=127.0.0.1"
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
vi /etc/kubernetes/controller-manager
#KUBE_CONTROLLER_MANAGER_ARGS=""
KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --pod-eviction-timeout=10s"
vi /etc/kubernetes/config
#KUBE_MASTER="--master=http://127.0.0.1:8080"
KUBE_MASTER="--master=http://172.16.232.129:8080"
systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager
systemctl start etcd kube-apiserver kube-scheduler kube-controller-manager
etcdctl mk /coreos.com/network/config '{"Network":"172.17.0.0/16"}'
# node
yum -y install kubernetes-node flannel
vi /etc/kubernetes/config
#KUBE_MASTER="--master=http://127.0.0.1:8080"
KUBE_MASTER="--master=http://172.16.232.129:8080"
vi /etc/kubernetes/kubelet
KUBELET_HOSTNAME="--hostname-override=172.16.232.129"
KUBELET_API_SERVER="--api-servers=http://172.16.232.129:8080"
#KUBELET_ARGS=""
KUBELET_ARGS="--pod-infra-container-image=kubernetes/pause"
vi /etc/sysconfig/flanneld
#FLANNEL_ETCD="http://127.0.0.1:2379"
FLANNEL_ETCD="http://172.16.232.129:2379"
#FLANNEL_ETCD_KEY="/atomic.io/network"
FLANNEL_ETCD_KEY="/coreos.com/network"
FLANNEL_OPTIONS=" -iface=ens33"
systemctl restart flanneld docker
systemctl start kubelet kube-proxy
systemctl enable flanneld kubelet kube-proxy
部分省略,详见以下。。
kubernetes学习1–centOS7.2使用yum安装kubernetes
kubectl config set-context kube-system --namespace=kube-system
kubectl config use-context kube-system
[root@centos kube]# kubectl create -f kube-dashboard_new.yaml
serviceaccount "kubernetes-dashboard" created
Error from server (BadRequest): error when creating "kube-dashboard_new.yaml": ClusterRoleBinding in version "v1beta1" cannot be handled as a ClusterRoleBinding: no kind "ClusterRoleBinding" is registered for version "rbac.authorization.k8s.io/v1beta1"
error validating "kube-dashboard_new.yaml": error validating data: [expected type array, for field spec.template.spec.containers[0].args, got string, found invalid field tolerations for v1.PodSpec]; if you choose to ignore these errors, turn validation off with --validate=false
听说换一个版本,就好了。
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard-no-rbac.yaml?gitio
wget 的脚本如下:
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Configuration to deploy release version of the Dashboard UI.
#
# Example usage: kubectl create -f
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
# Comment the following annotation if Dashboard must not be deployed on master
annotations:
scheduler.alpha.kubernetes.io/tolerations: |
[
{
"key": "dedicated",
"operator": "Equal",
"value": "master",
"effect": "NoSchedule"
}
]
spec:
containers:
- name: kubernetes-dashboard
image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.3
ports:
- containerPort: 9090
protocol: TCP
args:
# Uncomment the following line to manually specify Kubernetes API server Host
# If not specified, Dashboard will attempt to auto discover the API server and connect
# to it. Uncomment only if the default does not work.
# - --apiserver-host=http://my-address:port
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
ports:
- port: 80
targetPort: 9090
selector:
k8s-app: kubernetes-dashboard
TASK [atomic-k8s-master-post : Install the k8s dashboard] fails
最后改一下 apiserver 地址(–apiserver-host=http://172.16.232.129:8080),以及 image 地址 (image:docker.io/ist0ne/kubernetes-dashboard-amd64) ,就可以了。
kubernetes + kubernetes-dashboard 安装和各种踩坑
nodeport 没有分配啊,看来还要改一改,加上一个 type:NodePort 即可。
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
- port: 80
targetPort: 9090
selector:
k8s-app: kubernetes-dashboard
高级的来了,我不能访问装在虚机里的这个端口。==,先规避一下,装个 docker 版本的 vnc 玩玩。这个问题,先 mark 一下。
Mark-20170807-ubuntu vnc on docker
暴露 svc 端口到宿主机上,完美~
kubectl expose pods kubernetes-dashboard-2530647839-b6476 --port=9090 --external-ip=172.16.232.129
docker save eb9a804ae885 > /opt/soft/postgres.img
docker load < postgres.img
0 是移动到行首,$ 是移动到行尾
在vi中如何快速将文件移到行首和行尾?