docker详解教程博客
-
1.1docker容器管理商
-
1.2docker安装镜像
docker-ce的镜像源
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y yum-utils
安装docker的阿里镜像源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装:docker
yum makecache fast
yum -y install docker-ce
https://docs.docker.com/engine/install/centos/
https://www.cnblogs.com/yaoliuyang/p/13305375.html
-
1.3解决镜像下载问题
解决方案:
1.打开终端,su root 输入密码
2.打开 vim /etc/docker/daemon.json(若没有自行创建)
3.写入:
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}
这里的网站有很多,亲测这个最好用
4.重启一下docker:
-
1.4 解决docker search 回车太慢
yum install bind-utils -y
dig
dig @114.114.114.114 index.docker.io
-
1.5
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
ctrl+P+Q
不要自动启动容器
不要自动关闭启动
-
1.6
基础的命令
启动容器的命令
docker version
docker images
docker ps
docker ps --all
docker run -it --name=c1 centos:latest /bin/bash
docker删除
docker rm
docker save -o /home/centos.tar.gz
docker load <centos.tar.gz
yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.13-3.1.el7.x86_64.rpm
-
1.6 阿里云仓库制作
阿里云的镜像仓库
https://cr.console.aliyun.com/repository/cn-hangzhou/centos_other/centos_other_hx/details
阿里云的加速器
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
命令行登录
docker login --username=韩说不白说 registry.cn-hangzhou.aliyuncs.com
命令行打标记
docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/centos_other/centos_other_hx:[镜像版本号]
命令行推送
docker push registry.cn-hangzhou.aliyuncs.com/centos_other/centos_other_hx:v1
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
8YUE.3DAY
8月4日
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
8月5日
kubernetes
Linux modprobe命令详解
-
1.1 kubernets详解教程
- 编排工具 docker三剑客 compose swarm machine
- mesos marathon
- kubernetes 市场环境份额最大
- 新概念(devops 微服务,云计算,数据中台,大数据,Aiops)
- borg
https://github.com/kubernetes/kubernetes/releases
- master/node
- master:api server,scheduler,controller-manager
- node: kubelet 容器引擎(docker)
- pod 逻辑组件 label label selector 元数据
- label:key=value
- label selector
自主式pod
控制器管理的pod
job ctonjob
daemonset
HPA
service
AddOns:附件
——————————————————
创建两个pod 手动创建service
——————————————————
同一个pod内的多个容器间:lo
各pod之间的通信
-
CNI:
- flannel:
- calico 网络配置 网络策略
python:
网络运维:
解决暗转kunbet报错
注:如果要安装1.13.3版的话,指定安装yum install -y kubelet-1.13.3 kubeadm-1.13.3
kubectl-1.13.3即可 提示:假如gpgcheck报错的话(出现: Failing package is:
kubeadm-1.15.0-0.x86_64 GPG Keys are configured as:
https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg)
可以使用下面操作直接导入后再安装即可。
[root@k8s-node2:/root]# wget
https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
[root@k8s-node2:/root]# wget
https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
[root@k8s-node2:/root]# rpm --import yum-key.gpg
[root@k8s-node2:/root]# rpm --import rpm-package-key.gpg
master
kubeadm init --kubernetes-version=v1.15.0 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12
查看镜像名称
kubeadm config images list
镜像地址
http://mirror.azure.cn/help/gcr-proxy-cache.html
8月6日
使用脚本下载
set -o errexit
set -o nounset
set -o pipefail
##这里定义版本
KUBE_VERSION=v1.15.0
KUBE_PAUSE_VERSION=3.1
ETCD_VERSION=3.3.10
DNS_VERSION=1.3.1
GCR_URL=k8s.gcr.io
##这里就是写你要使用的仓库
DOCKERHUB_URL=registry.cn-hangzhou.aliyuncs.com/google_containers
##这里是镜像列表
images=(
kube-proxy:${KUBE_VERSION}
kube-scheduler:${KUBE_VERSION}
kube-controller-manager:${KUBE_VERSION}
kube-apiserver:${KUBE_VERSION}
pause:${KUBE_PAUSE_VERSION}
etcd:${ETCD_VERSION}
coredns:${DNS_VERSION}
)
##这里是拉取和改名的循环语句
for imageName in ${images[@]} ; do
docker pull $DOCKERHUB_URL/$imageName
docker tag $DOCKERHUB_URL/$imageName $GCR_URL/$imageName
docker rmi $DOCKERHUB_URL/$imageName
done
-
1.3 init报错解决方案
https://blog.csdn.net/zhydream77/article/details/81909939
[root@kuber ~]mkdir -p $HOME/.kube
[root@kuber ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@kuber ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health":"true"}
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
https://www.cnblogs.com/heian99/p/12173599.html
docker pull lizhenliang/flannel:v0.11.0-amd64
···
kubectl get pods -n kube-system
···
解决加入失败的问题
https://blog.csdn.net/daxiang52/article/details/105232527/
[root@kuber ~]# kubeadm token create
wx1obe.yj0taubskbn5vk95
[root@kuber ~]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
a7695a0d486d48706e54ec013489d9d91689ed28efd7e3b825764ea6687ed8bd
[root@kuber ~]#
kubectl run --help
[root@kuber ~]# kubectl run nginx-deploy --image=nginx:latest --port=80 --dry-run=true
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/nginx-deploy created (dry run)
kubectl get deployment
[root@kuber ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deploy 0/1 1 0 28s
[root@kuber ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deploy-bd7bc79f9-q6pwm 0/1 ImagePullBackOff 0 82s
nginx-deploy1-945b4ff46-4nmk7
1、如何删除
2、如何管理这个pod
3、ip ping不通怎么回事
4、怎么修改nginx内容
[root@kuber ~]# kubectl expose deployment nginx-deploy --name=nginx --port=80 --target-port=80
service/nginx exposed
[root@kuber ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5h24m
nginx ClusterIP 10.110.150.127 <none> 80/TCP 18s
kubectl get pods -n kube-system -o wide
[root@kuber ~]# kubect get svc -n kube-system
创建busybox
kubectl run client --image=busybox --replicas=1 -it --restart=Never
kubectl describe svc nginx
[root@kuber ~]# kubectl get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
client 1/1 Running 0 11m run=client
nginx-deploy-bd7bc79f9-hvj2p 1/1 Running 0 29m pod-template-hash=bd7bc79f9,run=nginx-deploy
nginx-deploy1-945b4ff46-mb69h 1/1 Running 0 28m pod-template-hash=945b4ff46,run=nginx-deploy1
nginx-deploy2-6d9bdbbf97-b928j 1/1 Running 0 37m pod-template-hash=6d9bdbbf97,run=nginx-deploy2
修改命令
kubectl edit svc nginx
[root@kuber ~]# kubectl scale --replicas=3 deployment nginx-deploy
deployment.extensions/nginx-deploy scaled
-
创建资源ed方式
- apiserver仅射手json格式
- yaml格式提供配置清单 apiserver可自动将其转为json格式在提交
大部分资源