Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Kubernetes Cluster using Kubespray
# Create Virtual env for Kubespray and make it active
virtualenv --system-site-packages kubespray_virtenv
source kubespray_virtenv/bin/activate
# Install Ansible and Kubespray to virtualenv
pip install kubespray
# Create kubespray config file
cat > ~/.kubespray.yml << EOF
kubespray_git_repo: "https://github.com/kubespray/kubespray.git"
kubespray_path: "$PWD/kubespray"
loglevel: "info"
EOF
# Prepare kubespray for deplyment
kubespray prepare --assumeyes --path $PWD/kubespray --nodes kubernetes_cluster_kube01 kubernetes_cluster_kube02 kubernetes_cluster_kube03 kubernetes_cluster_kube04
cat > kubespray/inventory/inventory.cfg << EOF
[kube-master]
kube01
kube02
[all]
kube01
kube02
kube03
kube04
[k8s-cluster:children]
kube-node
kube-master
[kube-node]
kube01
kube02
kube03
kube04
[etcd]
kube01
kube02
kube03
EOF
# Set password for kube user
test -d kubespray/credentials || mkdir kubespray/credentials
echo "kube123" > kubespray/credentials/kube_user
# Deploy Kubernetes cluster
kubespray deploy --assumeyes --user root --apps efk helm netchecker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.