port —————————————- service
nodeport ———————————– host
targetport ———————————- pod
containerport ——————————- container
访问流程:
client -> nodePort -> node local random Port -> Cluster-Ip Port -> targetPort -> containerPort
Kubernetes 集群的两种部署过程(daemon部署和容器化部署)以及glusterfs的应用!
[root@centos k8s-lnmp]# kubectl delete replicationcontroller k8s-php
replicationcontroller "k8s-php" deleted
[root@centos k8s-lnmp]# kubectl get pod
[root@centos k8s-lnmp]# kubectl get node
NAME STATUS AGE
127.0.0.1 NotReady 1d
猜测:
systemctl start kubelet
如何向部署好的Kubernetes上添加node?
systemctl stop iptables.service
systemctl disable iptables.service
systemctl stop firewalld.service
systemctl disable firewalld.service
搭建kubernetes时容易遇到的问题
yum install -y docker
systemctl start docker
yum install -y etcd kubernetes
systemctl daemon-reload # 重载所有修改过的配置文件
systemctl start etcd kube-apiserver.service kube-controller-manager kube-scheduler
systemctl enable etcd kube-apiserver.service kube-controller-manager kube-scheduler
systemctl daemon-reload
systemctl start kubelet.service kube-proxy docker
systemctl enable kubelet.service kube-proxy docker
Kubernetes
[root@centos k8s-lnmp]# kubectl -bash: _get_comp_words_by_ref: command not found
php--bash: _get_comp_words_by_ref: command not found
yum install -y bash-completion
cat >> /etc/profile
source <(kubectl completion bash)
(ctrl+D)
source /etc/profile
vi /etc/kubernetes/apiserver# 将ServiceAccount,去掉
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
systemctl restart kube-apiserver # 重启apiserver服务
跟风学Docker之六:Docker集群管理之Kubernetes
# 构建本地 registry
docker run -idt -p 5000:5000 --name registry -v /data/registry:/data/docker/registry registry
# 上传至本地 registry URL
docker tag lamp-php-mysql 127.0.0.1:5000/lamp-php-mysql
docker push 127.0.0.1:5000/lamp-php-mysql
docker tag lamp-php-mysql 127.0.0.1:5000/lamp-nginx
docker push 127.0.0.1:5000/lamp-nginx
docker tag lamp-php-mysql 127.0.0.1:5000/lamp-mysql
docker push 127.0.0.1:5000/lamp-mysql
Docker本地私有仓库搭建
wget https://rawgit.com/kubernetes/kubernetes/release-1.5/cluster/addons/dns/skydns-rc.yaml.sed -O skydns-rc.yaml
wget https://rawgit.com/kubernetes/kubernetes/release-1.5/cluster/addons/dns/skydns-svc.yaml.sed -O skydns-svc.yaml
kubectl create -f skydns-rc.yaml
kubectl create -f skydns-svc.yaml
Kubernetes 搭建kube-dns
cat busybox.yml
apiVersion: v1
kind: Pod
metadata:
labels:
name: busybox
role: master
name: busybox
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "360000"
kubectl create -f busybox.yml
kubectl exec -i -t busybox sh
nslookup lamp-mysql
部署kubernetes dns服务
The Service "kube-dns" is invalid: spec.clusterIP: Invalid value: "127.0.0.1": provided IP is not in the valid range
vi /etc/kubernetes/apiserver
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
You need to set the clusterIP to an IP in the “SERVICE_CLUSTER_IP_RANGE”, which is a CIDR range (typically a /16 or smaller) passed to the kube-apiserver process in the –service-cluster-ip-range flag. If you pick any address in that range you should no longer receive the above error.
Kubernetes: kube-dns Service Creation
docker pull registry.cn-hangzhou.aliyuncs.com/magina-k8s/dnsmasq-metrics-amd64:1.0
docker pull registry.cn-hangzhou.aliyuncs.com/magina-k8s/exechealthz-amd64:1.2
docker pull registry.cn-hangzhou.aliyuncs.com/magina-k8s/kubedns-amd64:1.9
docker pull registry.cn-hangzhou.aliyuncs.com/magina-k8s/kube-dnsmasq-amd64:1.4
docker tag registry.cn-hangzhou.aliyuncs.com/magina-k8s/dnsmasq-metrics-amd64:1.0 127.0.0.1:5000/dnsmasq-metrics-amd64:1.0
docker tag registry.cn-hangzhou.aliyuncs.com/magina-k8s/exechealthz-amd64:1.2 127.0.0.1:5000/exechealthz-amd64:1.2
docker tag registry.cn-hangzhou.aliyuncs.com/magina-k8s/kube-dnsmasq-amd64:1.4 127.0.0.1:5000/kube-dnsmasq-amd64:1.4
docker tag registry.cn-hangzhou.aliyuncs.com/magina-k8s/kubedns-amd64:1.9 127.0.0.1:5000/kubedns-amd64:1.9
docker push 127.0.0.1:5000/dnsmasq-metrics-amd64:1.0
docker push 127.0.0.1:5000/exechealthz-amd64:1.2
docker push 127.0.0.1:5000/kube-dnsmasq-amd64:1.4
docker push 127.0.0.1:5000/kubedns-amd64:1.9
阿里云kubernetes部署(v1.5.x)
Kubernetes 1.5 配置dns
然而,依旧没有成功,留着这个坑吧,下次再研究。
https://mritd.me/2016/10/29/set-up-kubernetes-cluster-by-kubeadm/
1-11111/k8s-lnmp
http://git.oschina.net/zhoufen111111/k8s-lnmp