k8s 1.20.5(补充)
1.根据前面1.15.0补充
2.初始化操作
selinux swap firewall关闭防火墙
swapoff -a 禁用交换空间
vim /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf 配置生效
3.yum源配置
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
4.安装管理命令由于安装镜像根据官方更新的定,所以安装时不一定是1.15版本的工具
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
指定版本
curl -LO https://dl.k8s.io/release/v1.21.0/bin/linux/amd64/kubectl
只需更改v1.21.0此处的版本位置
也可以直接
yum install -y kubelet-1.20.0-0 kubeadm-1.20.0-0 kubectl-1.20.0-0
5.启动服务
systemctl enable kubelet && systemctl start kubelet3
6.下载操作
kubeadm config images list 列出版本需求的软件
kubeadm config print init-defaults > kubeadm.conf
vim kubeadm.conf
imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers 阿里云镜像
kubeadm config images pull --config kubeadm.conf 批量下载
7.批量更改tag 删除镜像
#!/bin/bash
v=(
kube-apiserver:v1.20.5
kube-controller-manager:v1.20.5
kube-scheduler:v1.20.5
kube-proxy:v1.20.5
pause:3.2
etcd:3.4.13-0
coredns:1.7.0
)
for i in ${v[@]} ;
do
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$i
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$i k8s.gcr.io/$i
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$i
done
8.安装服务
kubeadm init --kubernetes-version=v1.20.5 --pod-network-cidr=107.16.0.0/16 --apiserver-advertise-address=192.168.182.100 安装服务
9.成功后操作
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Alternatively, if you are the root user, you can
run:
export KUBECONFIG=/etc/kubernetes/admin.conf
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/
Then you can join any number of worker nodes
by running the following on each as root:
kubeadm join 192.168.182.100:6443 --token
2r6868.0tgkbwuhgfcny57h \
--discovery-token-ca-cert-hash
sha256:48487c419b7ca45bcf6b46cb0aafeb6bac4d69593a4ab97d35f9c1a5d02ea329
10.部署网络
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml 部署flannel网络
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml 部署node节点后操作 就会变成ready
11.部署node节点
kubeadm join 192.168.182.100 :6443 --token
2r6868.0tgkbwuhgfcny57h \
--discovery-token-ca-cert-hash
sha256:48487c419b7ca45bcf6b46cb0aafeb6bac4d69593a4ab97d35f9c1a5d02ea329
12.部署dashbord界面管理
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml
更改 vim recommended.yaml

kubectl apply -f recommended.yaml 生效
13.访问界面
kubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name | grep namespace) | grep token 查看token
kubectl get svc --all-namespaces 查看映射的端口

浏览器访问
https://10.2.15.231:31000

14.基础命令
kubectl completion bash >/etc/bash_completion.d/kubectl 命令自动补全
kubectl get pods --all-namespaces 查看所有节点
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose 使用 replication controller, service, deployment 或者 pod 并暴露它作为一个 新的 Kubernetes
Service
run 在集群中运行一个指定的镜像
set 为 objects 设置一个指定的特征
Basic Commands (Intermediate):
explain 查看资源的文档
get 显示一个或更多 resources
edit 在服务器上编辑一个资源
delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
Deploy Commands:
rollout Manage the rollout of a resource
scale Set a new size for a Deployment, ReplicaSet or Replication Controller
autoscale 自动调整一个 Deployment, ReplicaSet, 或者 ReplicationController 的副本数量
Cluster Management Commands:
certificate 修改 certificate 资源.
cluster-info 显示集群信息
top Display Resource (CPU/Memory/Storage) usage.
cordon 标记 node 为 unschedulable
uncordon 标记 node 为 schedulable
drain Drain node in preparation for maintenance
taint 更新一个或者多个 node 上的 taints
Troubleshooting and Debugging Commands:
describe 显示一个指定 resource 或者 group 的 resources 详情
logs 输出容器在 pod 中的日志
attach Attach 到一个运行中的 container
exec 在一个 container 中执行一个命令
port-forward Forward one or more local ports to a pod
proxy 运行一个 proxy 到 Kubernetes API server
cp 复制 files 和 directories 到 containers 和从容器中复制 files 和 directories.
auth Inspect authorization
debug Create debugging sessions for troubleshooting workloads and nodes
Advanced Commands:
diff Diff live version against would-be applied version
apply 通过文件名或标准输入流(stdin)对资源进行配置
patch Update field(s) of a resource
replace 通过 filename 或者 stdin替换一个资源
wait Experimental: Wait for a specific condition on one or many resources.
kustomize Build a kustomization target from a directory or a remote url.
Settings Commands:
label 更新在这个资源上的 labels
annotate 更新一个资源的注解
completion Output shell completion code for the specified shell (bash or zsh)
Other Commands:
api-resources Print the supported API resources on the server
api-versions Print the supported API versions on the server, in the form of "group/version"
config 修改 kubeconfig 文件
plugin Provides utilities for interacting with plugins.
version 输出 client 和 server 的版本信息
命令居多还在学习中。。。
15.部署pod节点持续更新
根据官方提供的测试yaml
https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
执行
kubectl apply -f nginx.yaml
注意:有个问题默认master节点不能部署pod,在更改或者建立pod时,执行 kubectl taint nodes node3 node-role.kubernetes.io/master=:NoSchedule 开启允许maste节点部署pod
不允许调度 :kubectl taint nodes master1 node-role.kubernetes.io/master=:NoSchedule
界面展示

16.无状态程序和有状态程序
k8s运行程序存在无状态程序和有状态程序,可以理解为程序再运行过程中是否产生数据,且此数据必须保留。
所以在运行无状态程序时不考虑数据交互问题,运行有状态程序需要数据交互。类似于docker的-d选项。只不过此处需要写一个yaml文件来映射目录到实体机
k8s 1.20.5(补充)的更多相关文章
- Kubernetes实战指南(三十四): 高可用安装K8s集群1.20.x
@ 目录 1. 安装说明 2. 节点规划 3. 基本配置 4. 内核配置 5. 基本组件安装 6. 高可用组件安装 7. 集群初始化 8. 高可用Master 9. 添加Node节点 10. Cali ...
- Python之旅.第二章数据类型 3.19/3.20/3.21/3.22/3.23
一.数字类型 1.int类型: 基本使用: 用途:用于年龄,手机号,身份证号: 定义: age=18: 常用操作+内置方法: 正常的运算赋值: 进制转换: print(bin(3)); 把十进制3转换 ...
- 【LeetCode】排序 sort(共20题)
链接:https://leetcode.com/tag/sort/ [56]Merge Intervals (2019年1月26日,谷歌tag复习) 合并区间 Input: [[1,3],[2,6], ...
- Kubernetes全栈架构师(Kubeadm高可用安装k8s集群)--学习笔记
目录 k8s高可用架构解析 Kubeadm基本环境配置 Kubeadm系统及内核升级 Kubeadm基本组件安装 Kubeadm高可用组件安装 Kubeadm集群初始化 高可用Master及Token ...
- k8s 新版本 部署 Ingress-nginx controller
k8s 新版本 部署 Ingress-nginx controller 本篇主要记录一下 k8s 新版本 1.23.5 中如何搭建 ingress controller 以及里面的注意项 新版本和老版 ...
- 给JavaScript初学者的24条最佳实践
.fluid-width-video-wrapper { width: 100%; position: relative; padding: 0 } .fluid-width-video-wrapp ...
- 给JavaScript初学者的24条最佳实践(share)
不错的文章,留个备份 原文链接: net.tutsplus 翻译: 伯乐在线- yanhaijing译文链接: http://blog.jobbole.com/53199/ 作为“30 HTML和 ...
- opencv配置(2.49)
转载自浅墨大神http://blog.csdn.net/poem_qianmo/article/details/19809337 OpenCV2.4.9和2.4.8的配置几乎一样,唯一的区别在下文中的 ...
- OpenCV相机标定和姿态更新
原帖地址: http://blog.csdn.net/aptx704610875/article/details/48914043 http://blog.csdn.net/aptx704610875 ...
- html/css 两个div在同一行
在界面设计的时候,经常需要将两个div在同一行显示. 但是每次都会忘记怎么做,特此随笔,备忘. 如以下要将“第一个div”和“第二个div”显示在同一行: <div id="id1&q ...
随机推荐
- What's new in Dubbo 3.1.5 and 3.2.0-beta.4
在 1 月 27 日,新年伊始,Dubbo 3.1.5 和 3.2.0-beta.4 正式通过投票发布.本文将介绍发布的变化一览. Dubbo 3.1.5 版本是目前 Dubbo 3 的最新稳定版本, ...
- 基于Docker安装的Stable Diffusion使用CPU进行AI绘画
基于Docker安装的Stable Diffusion使用CPU进行AI绘画 由于博主的电脑是为了敲代码考虑买的,所以专门买的高U低显,i9配核显,用Stable Diffusion进行AI绘画的话倒 ...
- 在Spring Boot中整合Katharsis,来快速开发JSON API的Web应用
1 简介 我们进行Web API开发的时候,经常会使用Json格式的消息体,而Json格式非常灵活,不同的人会有不同的设计风格和实现,而JSON API提供了一套标准.但它并不提供直接实现. Kath ...
- sun.security.validator.ValidatorException: PKIXpath building failed: sun.security.provider,javax.net.ssT.SSLHandshakeExceptions.certpath.SunCertPathBuilderException
报错信息: sun.security.validator.ValidatorException: PKIXpath building failed: sun.security.provider,jav ...
- LeetCode_806. 写字符串需要的行数
题目 难度:简单 原文:https://leetcode-cn.com/problems/number-of-lines-to-write-string/ 题目 我们要把给定的字符串 S 从左到右写到 ...
- http八股 跨域的本质 请求行 请求头 请求体 xss
1小八股 介绍 http 请求分为三个部分,请求行,请求头,请求体 还有状态码的含义 https://juejin.cn/post/7096317903200321544 2tips Content- ...
- docker05-dockerfile
1.dockerfile是什么 Dockerfile是用来构建Docker镜像的构建文件,是由一系列命令和参数构成的脚本.可以理解为docker自己的语言编写的脚本. 2.Dockerfile内容基础 ...
- 让你VS Code的通过插件扩展,拥有了三头六臂
VS Code 有一个很强大的功能就是支持插件扩展,让你的编辑器仿佛拥有了三头六臂. 安装 VS Code 插件 提醒:当完成了vscode这些配置后,当我们换一台电脑时,不会还得重新配置吧?放心,我 ...
- vue+.net入门级书签项目
vu3+.net6 webApi 书签管理项目 前言 Gitee项目地址:https://gitee.com/zyplj/book-marks Github项目地址:https://github.co ...
- Axios、Vue组件-生命周期、计算属性、Slot插槽、自定义事件、v-router、钩子函数
Axios:网络通信 <script> var vm =new vue({ el:"#app", data(){ return{ info:{ //返回的数据必须和js ...