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. You will not be able to ping the Photon VM’s until you update iptables.
  • Reboot each vm with the command shutdown now -r

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!

Remember sharing is caring!

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

  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?

  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 [ ~ ]#

Leave a 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.