---
title: "kubeadm的yum和apt国内源"
author: "jaychang"
date: "2018-07-26T06:14:33Z"
tags: []
categories: ["开源软件"]
slug: "kubeadm-yum-apt"
draft: false
lastmod: "2018-07-26T06:14:33Z"
id: 2427522
url: "https://jaychang.iteye.com/blog/2427522"
---

转载自：https://www.jianshu.com/p/4b5f960a5bea

安装kubernetes的时候，需要安装kubelet, kubeadm等包，但k8s官网给的yum源是`packages.cloud.google.com`，国内访问不了，此时我们可以使用阿里云的yum仓库镜像。

阿里云上没有附Help说明连接，简单摸索了下，如下设置可用（centos）。注意不要开启check。

```
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
        http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
```

不过阿里云跟kubernetes同步不太及时，例如现在是1.8.1了，但是阿里云还是1.7.5。

如果你用的是ubuntu，也可以试试ustc的[mirror](https://link.jianshu.com?t=http%3A%2F%2Fmirrors.ustc.edu.cn%2Fkubernetes%2F)，更新比较及时。

```
cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main
EOF
```

&lt;!-- 如果是付费文章，未购买，则显示购买按钮 --&gt;

&lt;!-- 连载目录项 --&gt;

&lt;!-- 如果是付费文章 --&gt;

&lt;!-- 如果是付费连载，已购买，且作者允许赞赏，则显示付费信息和赞赏 --&gt;