0

First, I'm a complete ansible playbook noob. I'm busy trying to understand a clutser at my workplace. I tried following the readme's quick start guide whilst also following my companies kubespray fork. One thing that is really bothering me right now, is that configuration for our personal cluster is littered throughout the entire fork. Is there no way to separate my personal config files for the cluster from the kubespray repository? My idea is that I have a kubespray directory which is a fork, or master of the kubespray repository and when running 'kubespray' I supply my cluster's config to kubespray. Because currently I can't see how this is a clean and manageable way to maintain cluster resources with commits while also trying to update kubespray when I want to apply a new version. the current process seems like a utter mess!

  • As written, the current form of your question is prone to opinions and lots of discussion; ideally, one would post what you have tried, and what errors or problems in is producing, rather than "explain this theoretical setup that might not might not achieve my objectives" – mdaniel Sep 22 '20 at 19:48
  • @mdaniel yes you're right. I did end up finding a workflow which worked quite cleanly for me. It was essentially the same type of structure that Kubespray was promoting in their guide on integrating kubespray within larger ansible playbooks. – Jared Rieger Jan 06 '21 at 09:04

1 Answers1

1

So I ended up finding a nice solution that extrapolated away custom personal configuration from the kubespray repo. I assume this would actually be pretty obvious to seasoned Ansible users but the structure is as followed.

.
├── README.md
├── bin
├── docs
├── inventory
│   └── prod
│       ├── group_vars
│       │   ├── all
│       │   │   ├── all.yml
│       │   │   ├── azure.yml
│       │   │   ├── coreos.yml
│       │   │   ├── docker.yml
│       │   │   ├── oci.yml
│       │   │   └── openstack.yml
│       │   ├── balance.yml
│       │   ├── etcd.yml
│       │   └── k8s-cluster
│       │       ├── addons.yml
│       │       ├── ip.yml
│       │       ├── k8s-cluster.yml
│       │       ├── k8s-net-calico.yml
│       │       ├── k8s-net-canal.yml
│       │       ├── k8s-net-cilium.yml
│       │       ├── k8s-net-contiv.yml
│       │       ├── k8s-net-flannel.yml
│       │       ├── k8s-net-kube-router.yml
│       │       └── k8s-net-weave.yml
│       └── hosts.ini
└── kubespray

Now within the main dir you can run your kubespray commands like so

ansible-playbook \
        $(pwd)/kubespray/scale.yml \
        --inventory $(pwd)/inventory/prod/hosts.ini \
        --user root \
        --become \
        --become-user=root \
        --limit=$node \
        --extra-vars 'ansible_python_interpreter=/usr/bin/python3' \
        --flush-cache

The great thing about this structure is that you can now use git to track your changes to your infrastructure only and not having to worry about meddling with the files within Kubespray. Plus by having kubespray as a gitsubmodule you can also track the different versions with the configuration of servers. just general git goodness.

Anyway, I hope someone finds this useful. I've been using for a couple of months and found it far cleaner than having your configuration within the kubespray module.