Skip to content

Instantly share code, notes, and snippets.

@Chever-John
Last active February 8, 2025 10:35
Show Gist options
  • Select an option

  • Save Chever-John/bab8f2897e97ad63170889f6ad9a0897 to your computer and use it in GitHub Desktop.

Select an option

Save Chever-John/bab8f2897e97ad63170889f6ad9a0897 to your computer and use it in GitHub Desktop.
environments for kubernetes
#!/usr/bin/bash
# Generate encryption key for EncryptionConfig
export ENCRYPTION_KEY=$(head -c 32 /dev/urandom | base64)
# Array of cluster machine IPs
export NODE_IPS=(192.168.31.80 192.168.31.81 192.168.31.82)
# Array of hostnames corresponding to cluster IPs
export NODE_NAMES=(k8s-master-01 k8s-slave-01 k8s-slave-02)
# List of etcd cluster service addresses
export ETCD_ENDPOINTS="https://192.168.31.80:2379,https://192.168.31.81:2379,https://192.168.31.82:2379"
# IPs and ports for etcd inter-cluster communication
export ETCD_NODES="k8s-master-01=https://192.168.31.80:2380,k8s-slave-01=https://192.168.31.81:2380,k8s-slave-02=https://192.168.31.82:2380"
# kube-apiserver reverse proxy (kube-nginx) address and port
export KUBE_APISERVER="https://127.0.0.1:8443"
# Name of the network interface for inter-node communication
export IFACE="eth0"
# etcd data directory
export ETCD_DATA_DIR="/data/k8s/etcd/data"
# etcd WAL directory (preferably an SSD partition, or a different partition from ETCD_DATA_DIR)
export ETCD_WAL_DIR="/data/k8s/etcd/wal"
# Data directory for Kubernetes components
export K8S_DIR="/data/k8s/k8s"
# Docker data directory
export DOCKER_DIR="/data/k8s/docker"
## The following parameters generally do not need to be modified
# Token used for TLS Bootstrapping (can be generated using: head -c 16 /dev/urandom | od -An -t x | tr -d ' ')
export BOOTSTRAP_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# It's best to use a currently unused network segment for the service and pod network segments
# Service CIDR (not routable before deployment, routable within the cluster after deployment (guaranteed by kube-proxy))
export SERVICE_CIDR="10.96.0.0/12"
# Pod CIDR (recommended /16 segment, not routable before deployment, routable within the cluster after deployment (guaranteed by flanneld))
export CLUSTER_CIDR="10.244.0.0/16"
# Service port range (NodePort Range)
export NODE_PORT_RANGE="30000-32767"
# flanneld network configuration prefix
export FLANNEL_ETCD_PREFIX="/kubernetes/network"
# Kubernetes service IP (usually the first IP in SERVICE_CIDR)
export CLUSTER_KUBERNETES_SVC_IP="10.254.0.1"
# Cluster DNS service IP (pre-allocated from SERVICE_CIDR)
export CLUSTER_DNS_SVC_IP="10.254.0.2"
# Cluster DNS domain (without a trailing dot)
export CLUSTER_DNS_DOMAIN="cluster.local"
# Add the binary directory /opt/k8s/bin to PATH
export PATH=/opt/k8s/bin:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment