ubuntu16 安装 docker 和K8S指导

2023-05-16

docker安装包
https://download.csdn.net/download/van_peak/10590104

安装docker软件

root@ubuntu-129:/opt/docker# dpkg -i docker-ce_18.06.0_ce_3-0_ubuntu_amd64.deb

查看docker 安装版本

root@ubuntu-129:/opt/docker# docker version
Client:
 Version:           18.06.0-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        0ffa825
 Built:             Wed Jul 18 19:11:02 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.0-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       0ffa825
  Built:            Wed Jul 18 19:09:05 2018
  OS/Arch:          linux/amd64
  Experimental:     false

docker开机启动设置

root@ubuntu-129:/opt/docker# systemctl enable docker
Synchronizing state of docker.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable docker
root@ubuntu-129:/opt/docker# systemctl start docker

2.下载alpine 操作系统镜像

如果本地没有,会从docker远端仓库下载docker镜像

root@ubuntu-129:/opt/docker# docker run -it --rm alpine:latest sh
Unable to find image 'alpine:latest' locally
^C
root@ubuntu-129:/opt/docker# docker run -it --rm alpine:latest sh
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
050382585609: Pull complete
Digest: sha256:6a92cd1fcdc8d8cdec60f33dda4db2cb1fcdcacf3410a8e05b3741f44a9b5998
Status: Downloaded newer image for alpine:latest

配置阿里云docker远端仓库地址

vim  /etc/docker/daemon.json

{
"registry-mirror":["https://ozcouvlb.mirror.aliyuncs.com"]
}

使得文件生效,并重启docker:

root@ubuntu-129:~# systemctl  daemon-reload
root@ubuntu-129:~# systemctl  restart docker

以nginx 镜像为例测试新配置的远程仓库下载速度(还是很快的):

root@ubuntu-129:/opt/docker# docker run -it --rm nginx:latest sh
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
f5d23c7fed46: Pull complete
918b255d86e5: Pull complete
8c0120a6f561: Pull complete
Digest: sha256:eb3320e2f9ca409b7c0aa71aea3cf7ce7d018f03a372564dbdb023646958770b
Status: Downloaded newer image for nginx:latest
root@ubuntu-129:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              e445ab08b2be        2 weeks ago         126MB
alpine              latest              b7b28af77ffe        4 weeks ago         5.58MB
root@ubuntu-129:~# vim  /etc/docker/daemon.json
root@ubuntu-129:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
bf5f906e9868        nginx:latest        "sh"                3 minutes ago       Up 3 minutes        80/tcp              happy_tereshkova
root@ubuntu-129:~#

安装K8S

配置k8s下载源

vim /etc/apt/sources.list.d/kubernetes.list

deb http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main

但是更新源后报错调试证书错误: 

root@ubuntu-129:~# apt update
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial InRelease
获取:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-updates InRelease [109 kB]
获取:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-backports InRelease [107 kB]
获取:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-security InRelease [109 kB]
获取:5 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease [8,993 B]
错误:5 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease
  由于没有公钥,无法验证下列签名: NO_PUBKEY 6A030B21BA07F4FB
命中:6 http://nginx.org/packages/ubuntu xenial InRelease
正在读取软件包列表... 完成
W: GPG 错误:http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY 6A030B21BA07F4
E: 仓库 “http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease” 没有数字签名。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。

解决方案:

添加认证key

运行如下命令

其中recv-keys 是你之前6A030B21BA07F4FB的后8位

gpg --keyserver keyserver.ubuntu.com --recv-keys BA07F4FB

 导出你的key

gpg --export --armor BA07F4FB | apt-key add - 

 再次更新解决

root@ubuntu-129:~# apt update
获取:1 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease [8,993 B]
忽略:2 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial/main amd64 Packages
获取:2 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial/main amd64 Packages [28.4 kB]
命中:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial InRelease
命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-updates InRelease
命中:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-backports InRelease
命中:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-security InRelease
命中:7 http://nginx.org/packages/ubuntu xenial InRelease
已下载 28.4 kB,耗时 2秒 (11.9 kB/s)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有 413 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。

 

禁止基础设施

 4.2 K8S系统网络 配置

安装K8S

安装k8s

apt update && apt-get install -y kubelet=1.13.1-00 kubernetes-cni=0.6.0-00 kubeadm=1.13.1-00 kubectl=1.13.1-00

 设置开机启动

systemctl enable kubelet && systemctl start kubelet

5.2master 和node基础配置

vim /etc/hostname

master ----> node1--->node2

下面这个是ubutu18配置的地址,

因为ubuntu从17.10开始,已放弃在/etc/network/interfaces里固定IP的配置,而是改成netplan方式了。所以这里不会动

 

network:
  version: 2
  ethernets:
    ens33:   #配置的网卡名称
      dhcp4: false    #dhcp4关闭
      addresses: [192.168.236.177/24]   #设置本机IP及掩码
      gateway4: 192.168.236.2   #设置网关
      nameservers:
          addresses: [192.168.236.2]   #设置DNS
      optional: true

 

启动master节点(ubuntu-128)

root@ubuntu-128:/home/itcast/working# kubeadm init --config ./kubeadm.conf
[init] Using Kubernetes version: v1.13.1
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [ubuntu-128 localhost] and IPs [192.168.13.128 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [ubuntu-128 localhost] and IPs [192.168.13.128 127.0.0.1 ::1]
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [ubuntu-128 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.13.128]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 33.010980 seconds
[uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.13" in namespace kube-system with the configuration for the kubelets in the cluster
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "ubuntu-128" as an annotation
[mark-control-plane] Marking the node ubuntu-128 as control-plane by adding the label "node-role.kubernetes.io/master=''"
[mark-control-plane] Marking the node ubuntu-128 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: abcdef.0123456789abcdef
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join 192.168.13.128:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:341f71f586d22b71da8bf5fb9dfb5b72fbc3dbc8377a4752bcb5b1a6a04e84b8

按照提醒执行 下面三条指令

root@ubuntu-128:~# mkdir -p $HOME/.kube
root@ubuntu-128:~# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
root@ubuntu-128:~# sudo chown $(id -u):$(id -g) $HOME/.kube/config

测试k8s master节点情况

root@ubuntu-128:~# systemctl  enable kubelet
root@ubuntu-128:~# systemctl  start kubelet
root@ubuntu-128:~# kubectl get nodes
NAME         STATUS     ROLES    AGE     VERSION
ubuntu-128   NotReady   master   2m26s   v1.13.1
root@ubuntu-128:~# kubectl get cs
NAME                 STATUS    MESSAGE              ERROR
controller-manager   Healthy   ok
scheduler            Healthy   ok
etcd-0               Healthy   {"health": "true"}

 

其他node节点想要进入master节点,需要按照以下方式加入到集群中


To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join 192.168.13.128:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:341f71f586d22b71da8bf5fb9dfb5b72fbc3dbc8377a4752bcb5b1a6a04e84b8

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ubuntu16 安装 docker 和K8S指导 的相关文章

随机推荐

  • MySQL基础概述

    1 MySQL列类型 xff1a 带符号 无符号整数 xff0c 1 2 3 4 8字节长 xff0c FLOAT xff0c DOUBLE xff0c CHAR xff0c VARCHAR xff0c TEXT xff0c BLOB xf
  • Ubuntu11.04无线网络已禁用或设备未就绪

    以前在Win7下安装Ubuntu的时候 xff0c Ubuntu能够正常的连接到无线网 xff0c 但是在新买的笔记本上安装完Ubuntu11 04后 xff0c 出现了无线网络已经禁用的情况 xff0c 起初我以为是无线网络开关未开启 x
  • 第11章 远程联机服务器SSH/XDMCP/VNC/RDP

    1 用例 远程联机服务器 xff0c 提供用户远程透过文字或图形接口登入系统 2 静态 2 1 sshd 该服务提供远程联机 xff0c 并且数据加密 查看是否启动命令 service sshd start 设置系统启动是开启sshd服务命
  • ubuntu下找不到openssl/ssl.h

    编译代码 xff0c 总提示找不到openssl ssl h文件 xff0c 怀疑没有安装ssl 于是 sudo apt get install openssl 之后再编译 xff0c 还是提示同样的问题 于是查找 usr local in
  • 基于Docker的RStudio-server构建

    docker rstudio server Dockerfile for RStudio Server Docker image Pull the image from Docker Hub span class token functio
  • 回收站的路径 (CentOS6、Fedora10)

    刚开始装Linux系统的时候在root用户下向其他用户拷贝过一些文件 xff0c 后面就删除了 但在普通用户下 xff0c 没有删除的权限 xff0c 想修改权限后删除又找不到回收站的路径 xff08 刚开始还不知道搜索回收站的路径 xff
  • dmPython

    dmPython 达梦为适配 python 开发出 dmPython 接口 xff0c 在使用时还需要需要配置 DPI 运行环境 1 连接方式 dmPython提供两种连接方式 xff0c 不仅支持 key 61 value 形式传参连接
  • iOS 手动实现KVO / iOS KVO底层原理

    手动实现KVO KVO底层原理 git demo地址 看图 首先说一下Apple KVO的底层实现吧 内部实现原理 KVO是基于runtime机制实现的 xff0c 运用了一个isa swizzling技术 isa swizzling就是类
  • Flutter系列 - 引入本地图片

    Flutter系列 引入本地图片 1 大致文件结构 images myIcon png myIcon2 png lib pubspec yaml 2 步骤 在flutter中引入本地图片 我们先在项目根目录建立一个images文件夹 把本地
  • 如何写出优美的 C 代码 面向对象的 C

    基础知识 结构体 除了提供基本数据类型外 xff0c C 语言还提供给用户自己定制数据类型的能力 xff0c 那就是结构体 xff0c 在 C 语言中 xff0c 你可以用结构体来表示任何实体 结构体正是面向对象语言中的类的概念的雏形 xf
  • Flutter系列 --- Flutter与原生进行通信交互

    Flutter系列 Flutter与原生进行通信 项目git地址 demo地址 flutter无法直接调用系统相机 麦克风 定位 手机版本信息等 xff0c 此时就需要与原生方法进行交互了 需求 目前我们已经有了一个flutter项目 工程
  • antd Tab切换后子组件重复渲染

    antd Tab切换后子组件重复渲染 当切换到历史订单的时候 MyComponent被渲染了两次 内部的componentDidMount被执行了两次 原因是TabPane下面的组件创建后被保留在dom树中 切换的时候会再次创建 span
  • 教你一步一步开发iOS私有SDK 到并上传到cocoapods

    1 需求 我们要提供一个iOS 私有 SDK 对方可以通过cocoapods安装 并且只能看到头文件 2 大致流程 使用Xcode创建一个framework工程 在里面编写你需要提供的功能创建podspec文件 依赖这个framework
  • flutterInAppWebview 拦截微信h5支付UNKNOWN_URL_SCHEME

    调用代码如下 if urlStr startsWith 34 weixin wap pay 34 await launchUrl uri flutter webview拦截微信h5支付时 提示err UNKNOWN URL SCHEME 只
  • iOS点击推送消息跳转到指定页面

    最近一直在搞推送消息跳转指定页面 点击通知栏 执行以下方法 void application UIApplication application didReceiveRemoteNotification NSDictionary userI
  • iOS把UIImage对象保存到本地沙盒

    1 保存 void saveImage UIImage image NSArray paths 61 NSSearchPathForDirectoriesInDomains NSDocumentDirectory NSUserDomainM
  • 解决Xcode9 app 图标不显示 iOS11app图标不显示

    升级到iOS11系统下自己的项目桌面app图标不见了 自己在Xcode9下新建一个工程看一下 设置图标是显示的 但是假如CocoaPod就不显示了 多方查询发现 图标不显示主要是cocoaPod出现了问题 需要在podfile文件加入以下脚
  • 手把手教你使用sourceTree提交到git远程仓库

    需求 本地有一个项目想上传到git远程仓库 工具 sourceTree Step1 首先本地创建一个空的文件夹 空文件夹的路径写到图片2的目标路径上 例如图片3 图片1 图片2 图片3 Step2 点击克隆 让后打开如下 如果工作副本没有东
  • ES6函数参数的解构赋值

    函数参数的解构赋值 span class token function add span span class token punctuation span span class token punctuation span span cl
  • ubuntu16 安装 docker 和K8S指导

    docker安装包 https download csdn net download van peak 10590104 安装docker软件 root 64 ubuntu 129 opt docker dpkg i docker ce 1