跳过正文
  1. Posts/

k8s环境初始化配置shell脚本

·79 字·1 分钟·
Kubehan
作者
Kubehan
云原生知识栈:深度解析容器技术、Kubernetes、Istio、DevOps 实践、Prometheus 监控、Envoy 代理、Golang 开发及云原生架构与微服务趋势的专业博客
#!/bin/bash
# Initialize the machine. This needs to be executed on every machine.
# Add host domain name.
cat>>/etc/hosts<<EOF
192.168.137.140 k8s-master
192.168.137.141 k8s-node1
192.168.137.142 k8s-node2
EOF

# Modify related kernel parameters.
cat>/etc/sysctl.d/kubernetes.conf<<EOF
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl -p /etc/sysctl.d/kubernetes.conf>&/dev/null

# Turn off and disable the firewalld.
systemctl stop firewalld
systemctl disable firewalld

# Disable the SELinux.
sed -i 's/=enforcing/=disabled/' /etc/selinux/config

# Disable the swap.
sed -i 's/^.*swap/#&/g' /etc/fstab

# Reboot the machine.
reboot