Install Kubernetes on VMware Photon in 15 min. or less!

I just recently found a super easy way to install and learn Kubernetes. It also happens to work on Photon OS so that means it works across VMware products and services like Fusion, vSphere and VMware Cloud on AWS, I tested it on all of them so you’re good to go!

Pre-Reqs

  • Download the Photon Appliance from here
  • Deploy two Photon VM’s and name them k8s-server and k8s-node1
  • The default user and password is: root changme
  • On each VM edit the /etc/hostname file with it’s name
  • Make sure they both have an IP address and they can resolve each other by name. NOTE: if you don’t have DNS just edit the /etc/hosts file on each vm. Also, you will not be able to ping the Photon VM’s until you update iptables.
  • Reboot each vm with the command shutdown now -r
  • For a quick reference for configuring Photon OS see here

They should look something like this and we are ready to go! Your IP addresses will be different.

Let’s get started shall we

Login to your k8s-server and run the following commands:

systemctl start docker
systemctl enable docker
iptables -A INPUT -p tcp --dport 6443 -j ACCEPT
iptables -A INPUT -p udp --dport 8472 -j ACCEPT
iptables -A INPUT -p tcp --dport 10250 -j ACCEPT
curl -sfL https://get.k3s.io | sh -

Now get the node token so we can configure k8s-node1

Run the following command and copy the output to the clipboard

cat /var/lib/rancher/k3s/server/node-token

Now let’s configure our first node

Login to k8s-node1 and run the following commands:

systemctl start docker
systemctl enable docker
iptables -A INPUT -p udp --dport 8472 -j ACCEPT
iptables -A INPUT -p tcp --dport 10250 -j ACCEPT

Now let’s add k8s-node1 to the k8s-server

Login to k8s-node1 and run the following command by changing the items in red to reflect your environment:

curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

In my environment it looks like this:

curl -sfL https://get.k3s.io | K3S_URL=https://k8s-server:6443 K3S_TOKEN=K10605a9e8f817ec6bed6be4650e55352a63f98f8a27e508365c439d1ceb0947f1a::server:b33987c67370b88b82eda92829b93f47 sh -

If you want to add additional nodes just create new Photon VM’s k8s-node2, k8s-node3 and run the same commands on them

Now go back to k8s-server and list the nodes

Login to k8s-server and run the following command:

kubectl get nodes

You are now ready to deploy your first container

See my guide here!

Want to install the dashboard? See my guide here!

Remember sharing is caring!

22 Replies to “Install Kubernetes on VMware Photon in 15 min. or less!”

    • I assume this is for Photon OS? The default password for the root account is changeme , and you must change it when you first login. For security, Photon OS forbids common dictionary words for the root password.

  1. Ran all of the commands above, including setting up the 1st node, but back on the k8s-server, the “kubectl get nodes” doesn’t show the node. It only shows the master:

    root@k8s-server [ ~ ]# kubectl get nodes
    NAME STATUS ROLES AGE VERSION
    k8s-server Ready master 50m v1.19.3+k3s3

    Is there something I can look at for debugging, like some logs or something?

    • Make sure from both the server and node1 one you can resolve each other by name, remember it won’t respond to ping but at least check that the names resolve. Also be sure you run the iptables commands on both the server and node, they are different for each.

  2. root@k8s-master [ ~ ]# kubectl describe services folding-at-home
    Name: folding-at-home
    Namespace: default
    Labels: app=folding-at-home
    Annotations:
    Selector: app=folding-at-home
    Type: NodePort
    IP: 10.43.79.5
    Port: 7396/TCP
    TargetPort: 7396/TCP
    NodePort: 30181/TCP
    Endpoints: 10.42.3.4:7396
    Session Affinity: None
    External Traffic Policy: Cluster
    Events:
    root@k8s-master [ ~ ]# kubectl get nodes
    NAME STATUS ROLES AGE VERSION
    k8s-node2 Ready 27h v1.19.3+k3s3
    k8s-node3 Ready 27h v1.19.3+k3s3
    k8s-master Ready master 27h v1.19.3+k3s3
    k8s-node1 Ready 27h v1.19.3+k3s3
    root@k8s-master [ ~ ]#

  3. Pingback: How to install k8s dashboard using a node port | | VMtoCloud.com

  4. Great work. So good you got me started on Photon. But now I see VMWare moved it to GITHUB? And the UEFI versions (except for 4) break TDNF. So my question is whether VMWare is phasing Photon out? Should I be looking at Debian?

  5. All worked as planned until I joined k8s-node1 to the cluster. It joins, but comes up as ‘ready’ but with role ”.

    When I run a Kubectl command on the k8s-node1 I get: “The connection to the server localhost:8080 was refused – did you specify the right host or port?”.

    Kubectl describe node k8s-node1 (on the k8s-server) shows an error:
    “invalid capacity 0 on image filesystem”!?!

  6. This worked so well, thanks for the help!

    1 issue I’m having is that I can only access the nodeport on the node that the pod is running on. I’m not sure why, but I have opened all ports (just a lab environment in ESXi) and enabled forwarding in IPtables.

    Anyone else had this issue, if so has anyone found a solution?

    • Solved!!!

      added forwarding to iptables:
      iptables -P FORWARD ACCEPT

      and I added a file /etc/sysctl.d/kubernetes.conf with the following contents:

      net.ipv4.ip_forward = 1
      net.bridge.bridge-nf-call-ip6tables = 1
      net.bridge.bridge-nf-call-iptables = 1

      then ran sysctl –system

Leave a Reply to Gopikrishna Cancel reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.