I am trying to setup kubernetes master with ansible and one of the task showing . . .

Kalesha Gagguturu:
I am trying to setup kubernetes master with ansible and one of the task showing as
fatal: [kubemaster]: FAILED! => {"changed": false, "msg": "Source /etc/kubernetes/admin.conf not found"}
And I have task for initialization as

 - name: initialize the cluster
    ansible.builtin.command: kubeadm init --pod-network-cidr=10.244.0.0/16 >> cluster_initialized.txt
    args:
        chdir: $HOME
        creates: cluster_initialized.txt

And task to copy admin.conf file as

 - name: copy admin.conf to user's kube config
    ansible.builtin.copy:
        src: /etc/kubernetes/admin.conf
        dest: /home/gkalesha/.kube/config

Where as kubernetes master shows as

cat cluster_initialized.txt
[init] Using Kubernetes version: v1.14.10
[preflight] Running pre-flight checks
[preflight] The system verification failed. Printing the output from the verification:
KERNEL_VERSION: 3.10.0-1160.80.1.el7.x86_64
CONFIG_NAMESPACES: enabled
CONFIG_NET_NS: enabled
CONFIG_PID_NS: enabled
CONFIG_IPC_NS: enabled
CONFIG_UTS_NS: enabled
CONFIG_CGROUPS: enabled
CONFIG_CGROUP_CPUACCT: enabled
CONFIG_CGROUP_DEVICE: enabled
CONFIG_CGROUP_FREEZER: enabled
CONFIG_CGROUP_SCHED: enabled
CONFIG_CPUSETS: enabled
CONFIG_MEMCG: enabled
CONFIG_INET: enabled
CONFIG_EXT4_FS: enabled (as module)
CONFIG_PROC_FS: enabled
CONFIG_NETFILTER_XT_TARGET_REDIRECT: enabled (as module)
CONFIG_NETFILTER_XT_MATCH_COMMENT: enabled (as module)
CONFIG_OVERLAY_FS: enabled (as module)
CONFIG_AUFS_FS: not set - Required for aufs.
CONFIG_BLK_DEV_DM: enabled (as module)
OS: Linux
CGROUPS_CPU: enabled
CGROUPS_CPUACCT: enabled
CGROUPS_CPUSET: enabled
CGROUPS_DEVICES: enabled
CGROUPS_FREEZER: enabled
CGROUPS_MEMORY: enabled

And while running kubectl commands getting error as and this error is due to missing admin.conf (as per one of the article i found in communication forums)

kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Can some one help me on this?

Kalesha Gagguturu:
kubectl config view

apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

Al West:
It would appear that kubeadm init is not working. How come you are using version 1.14.10 - it is not longer supported.

Kalesha Gagguturu:
Oh ya
got it

Al West:
Also there is this role you can use:
https://github.com/geerlingguy/ansible-role-kubernetes

Kalesha Gagguturu:
Thanks yar
I will go through that

Kalesha Gagguturu:
As test phase I want to setup with playbooks first then want to move to roles as I am trying to understand and analyze the issues

Kalesha Gagguturu:
Is it if we are going for certification, does we have to setup Kubernetes cluster as well?

Al West:
I think you only need to know how to upgrade, not setup from scratch.

Kalesha Gagguturu:
Ok Thank you

Kalesha Gagguturu:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

[init] Using Kubernetes version: v1.25.4
[preflight] Running pre-flight checks
        [WARNING Firewalld]: firewalld is active, please ensure ports [6443 10250] are open or your cluster may not function correctly
        [WARNING Hostname]: hostname "kubemaster" could not be reached
        [WARNING Hostname]: hostname "kubemaster": lookup kubemaster on 192.168.145.2:53: no such host
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR CRI]: container runtime is not running: output: time="2022-11-24T20:24:49+05:30" level=fatal msg="unable to determine runtime API version: rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/containerd/containerd.sock: connect: no such file or directory\""
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

Al West:
you need a container runtime

Kalesha Gagguturu:
is it --pod-network-cidr should be at our kubemaster range?
Actually my kubemaster ip is 192.168.145.134

Kalesha Gagguturu:

sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-11-24 19:24:44 IST; 1h 2min ago
     Docs: <http://docs.docker.com>
 Main PID: 2522 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─2522 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --i...
           └─2528 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --run...

Kalesha Gagguturu:
I have docker installed in it

Al West:
you have multiple errors and warnings to sort out

Al West:
docker is not a supported for that version of kubernetes

Kalesha Gagguturu:
ok for this version of kubernetes which version of docker we required?

Al West:
You need containerd

Al West:
Ah you can use docker:
https://kubernetes.io/docs/setup/production-environment/container-runtimes/

I’d read the docs