RKE安装Kubernetes
生活随笔
收集整理的這篇文章主要介紹了
RKE安装Kubernetes
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
使用RKE部署kubernetes集群
一、基本環(huán)境準(zhǔn)備
1.1 環(huán)境準(zhǔn)備一
這里個人覺得可以和kubeadm的步驟一致,不過還是按照1.2配置的官方要求
1、關(guān)閉防火墻
systemctl stop firewalld && systemctl disable firewalld2、為iptables設(shè)置空規(guī)則
yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save3、關(guān)閉SELINUX
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config1.2 官方提供
1、創(chuàng)建一個新用戶(之后將用來運行docker,盡量不要用root用戶)
useradd lurious2、將新創(chuàng)建的用戶加入到docker組中,為了可以運行docker
usermod -aG docker lurious3、關(guān)閉swap 分區(qū)
swapoff -a4、執(zhí)行以下的腳本
for module in br_netfilter ip6_udp_tunnel ip_set ip_set_hash_ip ip_set_hash_net iptable_filter iptable_nat iptable_mangle iptable_raw nf_conntrack_netlink nf_conntrack nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat nf_nat_ipv4 nf_nat_masquerade_ipv4 nfnetlink udp_tunnel veth vxlan x_tables xt_addrtype xt_conntrack xt_comment xt_mark xt_multiport xt_nat xt_recent xt_set xt_statistic xt_tcpudp;doif ! lsmod | grep -q $module; thenecho "module $module is not present";fi;done5、更改sysctl設(shè)置
vi /etc/sysctl.conf net.ipv4.ip_forward = 1 net.bridge.bridge-nf-call-ip6tables = 1 # 官方中要求的 net.bridge.bridge-nf-call-iptables = 16、開啟6443端口(使用iptables)
以下語句執(zhí)行一個就可以
# Open TCP/6443 for all iptables -A INPUT -p tcp --dport 6443 -j ACCEPT # Open TCP/6443 for one specific IP iptables -A INPUT -p tcp -s your_ip_here --dport 6443 -j ACCEPT7、開啟6443端口(使用firewalld)
# Open TCP/6443 for all firewall-cmd --zone=public --add-port=6443/tcp --permanent firewall-cmd --reload# Open TCP/6443 for one specific IP firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4"source address="your_ip_here/32"port protocol="tcp" port="6443" accept' firewall-cmd --reload8、允許TCP
AllowTcpForwarding yes9、設(shè)置SSH(在RKE所在的宿主機上執(zhí)行)
一路空格就行
ssh-keygen10、將所生成的密鑰的公鑰分發(fā)到各個節(jié)點
ssh-copy-id lurious@192.168.109.10 ssh-copy-id lurious@192.168.109.11 ssh-copy-id lurious@192.168.109.12二、使用RKE(Rancher kubernetes engine)部署Kubernetes
2.1、查看版本
./rke version2.2 、rke配置文件
# If you intened to deploy Kubernetes in an air-gapped environment, # please consult the documentation on how to configure custom RKE images. # 配置harbor倉庫信息 private_registries:- url: harbor.lurious.com:8443user: adminpassword: "********" nodes: # 節(jié)點ip地址 - address: 192.168.109.10 # 遠(yuǎn)程連接的端口port: "22" # 主機間的通信地址internal_address: "" # 該節(jié)點 配制的角色,這里賦予三種角色。role:- controlplane- worker- etcd # 節(jié)點名稱hostname_override: newer1 # 遠(yuǎn)程連接的用戶user: lurious # docker socket 的配置 默認(rèn)為 /var/run/docker.sockdocker_socket: /var/run/docker.sockssh_key: "" # ssh的密鑰地址,即 最開始 配置 ssh-keygen 和 ssh-copy-id 兩個命令配置的ssh_key_path: ~/.ssh/id_rsa # ssh 的證書 這里沒有配置私鑰 空著就可以ssh_cert: ""ssh_cert_path: "" # 節(jié)點的 labelslabels: {} # 給節(jié)點設(shè)置污點,做調(diào)度策略用taints: [] - address: 192.168.109.11port: "22"internal_address: ""role:- controlplane- worker- etcdhostname_override: newer2user: luriousdocker_socket: /var/run/docker.sockssh_key: ""ssh_key_path: ~/.ssh/id_rsassh_cert: ""ssh_cert_path: ""labels: {}taints: [] services:etcd:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: []external_urls: []ca_cert: ""cert: ""key: ""path: ""uid: 0gid: 0snapshot: nullretention: ""creation: ""backup_config: nullkube-api:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: [] # 在kubernetes上創(chuàng)建任何服務(wù)的ip范圍 # 必須和 kube-controller 的地址范圍保持一致service_cluster_ip_range: 10.43.0.0/16 # 暴露在集群外的 NodePort 的端口范圍 如30000-32767service_node_port_range: ""pod_security_policy: false # docker鏡像拉去策略always_pull_images: falsesecrets_encryption_config: nullaudit_log: nulladmission_configuration: nullevent_rate_limit: nullkube-controller:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: []cluster_cidr: 10.42.0.0/16service_cluster_ip_range: 10.43.0.0/16scheduler:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: []kubelet:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: []cluster_domain: cluster.localinfra_container_image: ""cluster_dns_server: 10.43.0.10fail_swap_on: falsegenerate_serving_certificate: falsekubeproxy:image: ""extra_args: {}extra_binds: []extra_env: []win_extra_args: {}win_extra_binds: []win_extra_env: [] # 使用的網(wǎng)絡(luò)插件 這里默認(rèn)為 flannel插件 network:plugin: flanneloptions: {}mtu: 0node_selector: {}update_strategy: null authentication:strategy: x509sans: []webhook: null addons: "" addons_include: [] system_images:etcd: rancher/coreos-etcd:v3.4.13-rancher1alpine: rancher/rke-tools:v0.1.65nginx_proxy: rancher/rke-tools:v0.1.65cert_downloader: rancher/rke-tools:v0.1.65kubernetes_services_sidecar: rancher/rke-tools:v0.1.65kubedns: rancher/k8s-dns-kube-dns:1.15.10dnsmasq: rancher/k8s-dns-dnsmasq-nanny:1.15.10kubedns_sidecar: rancher/k8s-dns-sidecar:1.15.10kubedns_autoscaler: rancher/cluster-proportional-autoscaler:1.8.1coredns: rancher/coredns-coredns:1.7.0coredns_autoscaler: rancher/cluster-proportional-autoscaler:1.8.1nodelocal: rancher/k8s-dns-node-cache:1.15.13kubernetes: rancher/hyperkube:v1.19.3-rancher1flannel: rancher/coreos-flannel:v0.13.0-rancher1flannel_cni: rancher/flannel-cni:v0.3.0-rancher6calico_node: rancher/calico-node:v3.16.1calico_cni: rancher/calico-cni:v3.16.1calico_controllers: rancher/calico-kube-controllers:v3.16.1calico_ctl: rancher/calico-ctl:v3.16.1calico_flexvol: rancher/calico-pod2daemon-flexvol:v3.16.1canal_node: rancher/calico-node:v3.16.1canal_cni: rancher/calico-cni:v3.16.1canal_controllers: rancher/calico-kube-controllers:v3.16.1canal_flannel: rancher/coreos-flannel:v0.13.0-rancher1canal_flexvol: rancher/calico-pod2daemon-flexvol:v3.16.1weave_node: weaveworks/weave-kube:2.7.0weave_cni: weaveworks/weave-npc:2.7.0pod_infra_container: rancher/pause:3.2ingress: rancher/nginx-ingress-controller:nginx-0.35.0-rancher1ingress_backend: rancher/nginx-ingress-controller-defaultbackend:1.5-rancher1metrics_server: rancher/metrics-server:v0.3.6windows_pod_infra_container: rancher/kubelet-pause:v0.1.4 ssh_key_path: ~/.ssh/id_rsa ssh_cert_path: "" ssh_agent_auth: false # 開啟rbac認(rèn)證策略 authorization:mode: rbacoptions: {} ignore_docker_version: null kubernetes_version: "" private_registries: [] ingress:provider: ""options: {}node_selector: {}extra_args: {}dns_policy: ""extra_envs: []extra_volumes: []extra_volume_mounts: []update_strategy: null # 集群名稱 cluster_name: "cluster-newer" # 云服務(wù)提供商 cloud_provider:name: "" prefix_path: "" win_prefix_path: "" addon_job_timeout: 0 bastion_host:address: ""port: ""user: ""ssh_key: ""ssh_key_path: ""ssh_cert: ""ssh_cert_path: "" monitoring:provider: ""options: {}node_selector: {}update_strategy: nullreplicas: null restore:restore: falsesnapshot_name: "" dns: null2.3、開始安裝
./rke up總結(jié)
以上是生活随笔為你收集整理的RKE安装Kubernetes的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6G愿景与需求:数字孪生、智能泛在
- 下一篇: hp计算机如何进入启动界面,HP笔记本怎