加速
dockerhub加速地址:
--registry-mirror=https://8mgus5o0.mirror.aliyuncs.com
Ubuntu添加阿里云kubernetes源:
# 添加可信密钥curl -s http://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -#添加源地址cat </etc/apt/sources.list.d/kubernetes.listdeb http://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial mainEOF#更新apt-get update#安装apt-get install -y kubelet kubeadm kubectl
国外资源
需要安装shadowsock
安装SS客户端
apt-get install python-pip python-setuptools m2cryptopip install shadowsocks
在某个目录创建ss.json文件,内容如下:
{"server":"my_server_ip","server_port":8388,"local_address": "127.0.0.1","local_port":1080,"password":"mypassword","timeout":300,"method":"aes-256-cfb","fast_open": false,"workers": 1}
启动命令:
sslocal -c ss.json &
转换HTTP代理
Shadowsocks默认是用Socks5协议的,对于Terminal的get,wget等走Http协议的地方是无能为力的,所以需要转换成Http代理,加强通用性,这里使用的转换方法是基于Polipo的。
输入命令安装Polipo:
sudo apt-get install polipo
修改配置文件:/etc/polipo/config
,如下:
# This file only needs to list configuration variables that deviate# from the default values. See /usr/share/doc/polipo/examples/config.sample# and "polipo -v" for variables you can tweak and further information.logSyslog = falselogFile = "/var/log/polipo/polipo.log"socksParentProxy = "127.0.0.1:1080"socksProxyType = socks5chunkHighMark = 50331648objectHighMark = 16384serverMaxSlots = 64serverSlots = 16serverSlots1 = 32proxyAddress = "0.0.0.0"proxyPort = 8123
重启Polipo:
/etc/init.d/polipo restart
验证代理是否正常工作:
export http_proxy=”http://127.0.0.1:8123/” curl www.google.com
如果正常,就会返回抓取到的Google网页内容。
设置docker代理配置
mkdir /etc/systemd/system/docker.service.dvim /etc/systemd/system/docker.service.d/http-proxy.conf
内容如下:
[Service]Environment="ALL_PROXY=socks5://127.0.0.1:1080"
验证下:
root@:~#systemctl show --property=Environment dockerEnvironment=ALL_PROXY=socks5://127.0.0.1:1080
重启服务:
root@:~# systemctl daemon-reloadroot@:~# systemctl restart docker
然后使用脚本,将国外资源下载后上传到自己的harbor仓库中,脚本如下:
#!/bin/bashimages=(gcr.io/google_containers/kube-proxy-amd64:v1.6.1 gcr.io/google_containers/kube-apiserver-amd64:v1.6.1 gcr.io/google_containers/kube-scheduler-amd64:v1.6.1 gcr.io/google_containers/kube-controller-manager-amd64:v1.6.1 gcr.io/google_containers/kube-proxy-amd64:v1.6.0 gcr.io/google_containers/kube-controller-manager-amd64:v1.6.0 gcr.io/google_containers/kube-apiserver-amd64:v1.6.0 gcr.io/google_containers/kube-scheduler-amd64:v1.6.0 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.1 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.1 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1 gcr.io/google_containers/etcd-amd64:3.0.17 quay.io/coreos/flannel:v0.7.0-amd64 gcr.io/google_containers/pause-amd64:3.0)for imageName in ${images[@]} ;do echo $imageName echo ${imageName##*/} docker pull $imageName docker tag $imageName harbor.jdpoc.com/k8s/${imageName##*/} docker push harbor.jdpoc.com/k8s/${imageName##*/}done
1.10.1 下载镜像:
#!/bin/bashimages=(gcr.io/google_containers/kube-proxy-amd64:v1.6.1 gcr.io/google_containers/kube-apiserver-amd64:v1.6.1 gcr.io/google_containers/kube-scheduler-amd64:v1.6.1 gcr.io/google_containers/kube-controller-manager-amd64:v1.6.1 gcr.io/google_containers/kube-proxy-amd64:v1.10.1gcr.io/google_containers/kube-controller-manager-amd64:v1.10.1gcr.io/google_containers/kube-apiserver-amd64:v1.10.1gcr.io/google_containers/kube-scheduler-amd64:v1.10.1 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.1 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.1 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1gcr.io/google_containers/etcd-amd64:3.1.12 quay.io/coreos/flannel:v0.9.1-amd64 gcr.io/google_containers/pause-amd64:3.1)for imageName in ${images[@]} ; do echo $imageName echo ${imageName##*/} docker pull $imageName docker tag $imageName harbor.jdpoc.com/k8s/${imageName##*/} docker push harbor.jdpoc.com/k8s/${imageName##*/}done