背景:

每次使用功能kubeadm的时候都需要提前准备好镜像,为什么自定义使用的镜像源呢?

在没有翻越围墙时

kubeadm init --kubernetes-version=v1.13.0 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.146.10

	[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.13.0: output: Trying to pull repository k8s.gcr.io/kube-apiserver ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 108.177.97.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.13.0: output: Trying to pull repository k8s.gcr.io/kube-controller-manager ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 108.177.97.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.13.0: output: Trying to pull repository k8s.gcr.io/kube-scheduler ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-proxy:v1.13.0: output: Trying to pull repository k8s.gcr.io/kube-proxy ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 108.177.97.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/pause:3.1: output: Trying to pull repository k8s.gcr.io/pause ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 108.177.97.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/etcd:3.2.24: output: Trying to pull repository k8s.gcr.io/etcd ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused
, error: exit status 1
[ERROR ImagePull]: failed to pull image k8s.gcr.io/coredns:1.2.6: output: Trying to pull repository k8s.gcr.io/coredns ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 108.177.125.82:443: getsockopt: connection refused
, error: exit status 1

去官网翻翻资料,看下是否可以直接配置

https://kubernetes.io/zh/docs/setup/independent/create-cluster-kubeadm/

使用kubeadm images list 可以查看到kubeadm默认使用的镜像列表

同样我们是不是可以改变kubeadm使用的默认镜像呢?

首先我们先看一下kubeadm命令

#让我们看下config选项
[root@K8s-master ~]# kubeadm config -h There is a ConfigMap in the kube-system namespace called "kubeadm-config" that kubeadm uses to store internal configuration about the
cluster. kubeadm CLI v1.8.0+ automatically creates this ConfigMap with the config used with 'kubeadm init', but if you
initialized your cluster using kubeadm v1.7.x or lower, you must use the 'config upload' command to create this
ConfigMap. This is required so that 'kubeadm upgrade' can configure your upgraded cluster correctly. Usage:
kubeadm config [flags]
kubeadm config [command] Available Commands:
images Interact with container images used by kubeadm.
migrate Read an older version of the kubeadm configuration API types from a file, and output the similar config object for the newer version.
print Print configuration
upload Upload configuration about the current state, so that 'kubeadm upgrade' can later know how to configure the upgraded cluster.
view View the kubeadm configuration stored inside the cluster. Flags:
-h, --help help for config
--kubeconfig string The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations are searched for an existing KubeConfig file. (default "/etc/kubernetes/admin.conf") Global Flags:
--log-file string If non-empty, use this log file
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
-v, --v Level log level for V logs Use "kubeadm config [command] --help" for more information about a command.

images 查看kubeadm使用的镜像

print 打印配置

因为我需要更改的是kubeadm使用的镜像所以继续使用kuberadm config images -h 查看帮助

[root@K8s-master ~]# kubeadm config images -h
Interact with container images used by kubeadm. Usage:
kubeadm config images [flags]
kubeadm config images [command] Available Commands:
list Print a list of images kubeadm will use. The configuration file is used in case any images or image repositories are customized.
pull Pull images used by kubeadm. Flags:
-h, --help help for images Global Flags:
--kubeconfig string The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations are searched for an existing KubeConfig file. (default "/etc/kubernetes/admin.conf")
--log-file string If non-empty, use this log file
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
-v, --v Level log level for V logs Use "kubeadm config images [command] --help" for more information about a command.

发现这里只有一个list 和pull了可以判断查看配置可以直接用 kubeadm config print

#先尝试打印出配置文件
[root@K8s-master ~]# kubeadm config print
Error: missing subcommand; "print" is not meant to be run on its own
Usage:
kubeadm config print [flags]
kubeadm config print [command] Available Commands:
init-defaults Print default init configuration, that can be used for 'kubeadm init'
join-defaults Print default join configuration, that can be used for 'kubeadm join' Flags:
-h, --help help for print Global Flags:
--kubeconfig string The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations are searched for an existing KubeConfig file. (default "/etc/kubernetes/admin.conf")
--log-file string If non-empty, use this log file
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
-v, --v Level log level for V logs Use "kubeadm config print [command] --help" for more information about a command. error: missing subcommand; "print" is not meant to be run on its own #发现报错,根据提示我们是需要打印init-defaults init的默认配置文件
[root@K8s-master ~]# kubeadm config print init-defaults
apiVersion: kubeadm.k8s.io/v1beta1
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 1.2.3.4
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: k8s-master
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta1
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controlPlaneEndpoint: ""
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.13.0
networking:
dnsDomain: cluster.local
podSubnet: ""
serviceSubnet: 10.96.0.0/12
scheduler: {}

yaml格式的配置文件,

可以看到这里的默认image仓库使用的是k8s.gcr.io

imageRepository: k8s.gcr.io

此时我们把打印的配置文件copy到一个文件中new.yaml

把其中的imageRepository:改成我们的仓库 如 mirrorgooglecontainers

在使用kubeadm config images list --config ./new.yaml

[root@K8s-master ~]# kubeadm config images list --config new.yaml
W0116 10:29:05.964789 100887 common.go:86] WARNING: Detected resource kinds that may not apply: [InitConfiguration JoinConfiguration]
[config] WARNING: Ignored YAML document with GroupVersionKind kubeadm.k8s.io/v1beta1, Kind=JoinConfiguration
mirrorgooglecontainers/kube-apiserver:v1.13.0
mirrorgooglecontainers/kube-controller-manager:v1.13.0
mirrorgooglecontainers/kube-scheduler:v1.13.0
mirrorgooglecontainers/kube-proxy:v1.13.0
mirrorgooglecontainers/pause:3.1
mirrorgooglecontainers/etcd:3.2.24
mirrorgooglecontainers/coredns:1.2.6

可以看到此时使用的镜像已经改过来了

但是问题又来了,mirrorgooglecontainers并没有所以的组件镜像。。

可以替换一个有所以组件的镜像源网站,

亦或者在我们先前看到的yaml文件中定义,但是碍于刚上手k8s这个实在没有办法自定义这个yaml文件。

但不妨这也是一个解决路径。

先留着

kubeadm 默认镜像配置问题引申的更多相关文章

  1. R语言-默认镜像设置

    问题1:如何设置默认镜像 你希望下载某些R包,因此希望设定默认的CRAN网站镜像,这样R每次下载时不需要你选择镜像. 解决方案 该方案要求用户R系统中包含一个.Rprofile文件,如方法3.16描述 ...

  2. docker切换默认镜像源

    docker切换默认镜像源   基于 debian8 默认安装的 docker 镜像源是在国外,pull 镜像的时候奇慢无比,需要自己手动切换成国内的镜像源. 1. 修改配置文件 docker 默认的 ...

  3. 在Centos7 更改Docker默认镜像和容器的位置

    图片出处:https://bobcares.com/wp-content/uploads/docker-change-directory.jpg 一.Why? 通常,当你开始使用docker时,我们并 ...

  4. Mirror--不同SQL Server版本使用的默认镜像端点加密算法不同

    在搭建镜像时遇到一个小问题,搭建镜像时报错,排查好半天,对证书/用户/登陆/连接授权等方面都做了逐一排查,未发现异常,最后生成镜像端点创建脚本时,才发现问题原因: 镜像主节点(10.50.4276)的 ...

  5. CentOS7更改Docker默认镜像和容器存储位置

    图片出处:https://bobcares.com/wp-content/uploads/docker-change-directory.jpg 一.Why? 通常,当你开始使用docker时,我们并 ...

  6. [K8S]kubeadm国内镜像安装方式

    使用国内镜像站 sudo apt-get update && sudo apt-get install -y apt-transport-https curl sudo curl -s ...

  7. 修改Docker默认镜像和容器的存储位置

    一.Why Docker默认的镜像和容器存储位置在/var/lib/docker中,如果仅仅是做测试,我们可能没有必要修改,但是当大量使用的时候,我们可能就要默认存储的位置了. 二.How 2.1 修 ...

  8. windows及linux环境下修改pip的默认镜像源的方法

    1. 在windows环境下 临时修改 使用清华大学的源安装numpy包. pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple ...

  9. Docker】如何修改Docker的默认镜像存储位置

    江湖有多大,坑就有多多……我使用的服务器, 系统盘根目录只有20G, 默认Docker 的镜像文件是安装在/var/lib/docker 目录下的, 这样的话我根本装不了太多的镜像,之前遇到一种情况就 ...

随机推荐

  1. [vijos1725&bzoj2875]随机数生成器<矩阵乘法&快速幂&快速乘>

    题目链接:https://vijos.org/p/1725 http://www.lydsy.com/JudgeOnline/problem.php?id=2875 这题是前几年的noi的题,时间比较 ...

  2. Spring中的设计模式:工厂方法模式

    导读 工厂方法模式是所有设计模式中比较常用的一种模式,但是真正能搞懂用好的少之又少,Spring底层大量的使用该设计模式来进行封装,以致开发者阅读源代码的时候晕头转向. 文章首发于微信公众号[码猿技术 ...

  3. API参数如何验证?别纠结,拿去用就是

    今天我们主要分享项目实战中,另一种常用的参数校验框架 Hibernate Validator,请准备好小板凳,我们的分享开始. 1. 是啥? 先抛一张图,锻炼一下你的观察力. 通过上图有没有发现,数据 ...

  4. 手工注入——sql server (mssql)注入实战和分析

    前言 首先要对sql server进行初步的了解.常用的全部变量@@version:返回当前的Sql server安装的版本.处理器体系结构.生成日期和操作系统.@@servername:放回运行Sq ...

  5. 001_Three.js中的跨域问题

    001_Three.js中的跨域问题 [情景描述]: 在初始化模型,引入字体和纹理皮肤图片的时候,由于跨域问题,出现了以下提示: Access to image at 'file:///F:/User ...

  6. 微信小程序页面传值详解

    我们知道,在微信小程序中,从一个页面转到另一个页面,一般情况下可以通过navigate或redirect时候的url来携带参数,然后在目标页面的onLoad函数参数中获取这些url参数.例如:   / ...

  7. LeetCode | 1013. 将数组分成和相等的三个部分

    给定一个整数数组 A,只有我们可以将其划分为三个和相等的非空部分时才返回 true,否则返回 false. 形式上,如果我们可以找出索引i+1 < j且满足(A[0] + A[1] + ... ...

  8. 使用Putty登录亚马逊云主机

    亚马逊云主机配置之后会提示 提供一个 pem证书, 打开 SSH 客户端.(了解操作方法 使用 PuTTY 连接) 找到您的私有密钥文件(test001.pem).向导会自动检测您用于启动实例的密钥. ...

  9. vector数组的相关知识

    Vector 类实现了一个动态数组.和 ArrayList 很相似,但是两者是不同的: Vector 是同步访问的. Vector 包含了许多传统的方法,这些方法不属于集合框架. Vector 主要用 ...

  10. TCP协议的安全性分析

    有算法就有破解法,因为它们都遵循了一定的数据结构和数学知识.所以网络安全是一个相对的概念,不可能出现绝对的安全!作为当今最流行的网络协议--TCP也是如此.那么TCP的安全问题究竟是哪些因素引起的呢? ...