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(补充)的更多相关文章

  1. Kubernetes实战指南(三十四): 高可用安装K8s集群1.20.x

    @ 目录 1. 安装说明 2. 节点规划 3. 基本配置 4. 内核配置 5. 基本组件安装 6. 高可用组件安装 7. 集群初始化 8. 高可用Master 9. 添加Node节点 10. Cali ...

  2. Python之旅.第二章数据类型 3.19/3.20/3.21/3.22/3.23

    一.数字类型 1.int类型: 基本使用: 用途:用于年龄,手机号,身份证号: 定义: age=18: 常用操作+内置方法: 正常的运算赋值: 进制转换: print(bin(3)); 把十进制3转换 ...

  3. 【LeetCode】排序 sort(共20题)

    链接:https://leetcode.com/tag/sort/ [56]Merge Intervals (2019年1月26日,谷歌tag复习) 合并区间 Input: [[1,3],[2,6], ...

  4. Kubernetes全栈架构师(Kubeadm高可用安装k8s集群)--学习笔记

    目录 k8s高可用架构解析 Kubeadm基本环境配置 Kubeadm系统及内核升级 Kubeadm基本组件安装 Kubeadm高可用组件安装 Kubeadm集群初始化 高可用Master及Token ...

  5. k8s 新版本 部署 Ingress-nginx controller

    k8s 新版本 部署 Ingress-nginx controller 本篇主要记录一下 k8s 新版本 1.23.5 中如何搭建 ingress controller 以及里面的注意项 新版本和老版 ...

  6. 给JavaScript初学者的24条最佳实践

    ­.fluid-width-video-wrapper { width: 100%; position: relative; padding: 0 } .fluid-width-video-wrapp ...

  7. 给JavaScript初学者的24条最佳实践(share)

    不错的文章,留个备份 原文链接: net.tutsplus   翻译: 伯乐在线- yanhaijing译文链接: http://blog.jobbole.com/53199/ 作为“30 HTML和 ...

  8. opencv配置(2.49)

    转载自浅墨大神http://blog.csdn.net/poem_qianmo/article/details/19809337 OpenCV2.4.9和2.4.8的配置几乎一样,唯一的区别在下文中的 ...

  9. OpenCV相机标定和姿态更新

    原帖地址: http://blog.csdn.net/aptx704610875/article/details/48914043 http://blog.csdn.net/aptx704610875 ...

  10. html/css 两个div在同一行

    在界面设计的时候,经常需要将两个div在同一行显示. 但是每次都会忘记怎么做,特此随笔,备忘. 如以下要将“第一个div”和“第二个div”显示在同一行: <div id="id1&q ...

随机推荐

  1. day15-声明式事务

    声明式事务 1.事务分类 编程式事务 Connection connection = JdbcUtils.getConnection(); try{ //1.先设置事务不要提交 connection. ...

  2. ClickHouse(12)ClickHouse合并树MergeTree家族表引擎之AggregatingMergeTree详细解析

    目录 建表语法 查询和插入数据 数据处理逻辑 ClickHouse相关资料分享 AggregatingMergeTree引擎继承自 MergeTree,并改变了数据片段的合并逻辑.ClickHouse ...

  3. 线程、GIL、协程

    1.多进程实现TCP服务端并发 1.之前我们学习了一个服务端对应一个客户端的操作,但是我们无法实现一个服务端对应多个客户端的操作.因此我们需要在pycharm的右上角点击倒三角,选择Edit Conf ...

  4. 不像JVM的JVM

    1.面向对象 面向对象的思想:将功能封装到对象中,通过对象去实现 面向对象的目的:将复杂的事情简单化,将以前过程中的执行者变成了指挥者且符合现在人们的思考习惯 面向对象的三大特征: 封装:将对象的实现 ...

  5. .NET Core 日志记录程序和常用日志记录框架

    本文主要内容为.NET Core的日志记录程序和常使用的日志记录框架的简单使用 首先,打开VS2019新建一个ASP.NET Core Web Api项目,项目创建好后会有一个集成好的天气预报的类和控 ...

  6. 一牛X同学的报告分享

    https://indico.cern.ch/event/743699/contributions/3072640/attachments/1750517/2836233/ARIES_Workshop ...

  7. 【Go语言基础】slice

    一.概述 数组(Array)的长度在定义之后无法再次修改:数组是值类型,每次传递都将产生一份副本. 显然这种数据结构无法完全满足开发者的真实需求.Go语言提供了数组切片(slice)来弥补数组的不足. ...

  8. 通过Rsync实现文件远程备份

    转载:博客园 https://www.cnblogs.com/huligong1234/p/13513395.html

  9. rin和快速迭代

    链接:https://ac.nowcoder.com/acm/contest/3002/E rin最近喜欢上了数论. 然而数论实在太复杂了,她只能研究一些简单的问题. 这天,她在研究正整数因子个数的时 ...

  10. [专题总结]Gridea快速免费搭建个人博客

    介绍 或许你很想把你所知道的问题写出来,或许你文思泉涌,想给大家分享.我相信,你一定能写好博客,只要坚持,就可以了. 或许大家会不理解,为什么不用大平台的博客呢?或许你稍微了解就会知道,现在的博客平台 ...