Sure, I’d be glad to help you assess your Kubernetes setup on your Ubuntu Server 20.04 LTS. Below is a comprehensive, step-by-step guide to ensure that Kubernetes is correctly installed and functioning as expected. This assessment will cover verifying the installation, checking cluster health, deploying a test application, and validating networking and system components.
Step 1: Verify Kubernetes Installation
1.1. Check Kubernetes Version
Ensure that both the kubectl client and the Kubernetes cluster are correctly installed and accessible.
kubectl version --client
kubectl version
- Expected Output:
kubectl version --client should display the client version.
kubectl version should show both client and server (cluster) versions.
1.2. Ensure kubectl is Configured Correctly
Ensure that kubectl is pointing to the correct cluster configuration.
kubectl config view
- Check: The output should display the clusters, contexts, and users. Ensure that the current context is set to your intended cluster.
Step 2: Inspect Cluster Information
2.1. Get Cluster Info
Retrieve basic information about the Kubernetes cluster.
kubectl cluster-info
- Expected Output:
- URLs for the Kubernetes master and services like Kubernetes DNS.
2.2. List All Nodes
Check the status of all nodes in the cluster.
kubectl get nodes
- Expected Output:
- A list of nodes with their status. Status should be
Ready.
Example:
NAME STATUS ROLES AGE VERSION
ubuntu-node1 Ready master 10d v1.20.0
Step 3: Examine System Pods and Services
3.1. List All Pods in All Namespaces
Inspect the status of all pods, especially those in the kube-system namespace which are critical for cluster operations.
kubectl get pods --all-namespaces
- Check:
- All system pods (
kube-system namespace) should be in the Running or Completed state.
- No pods should be in
CrashLoopBackOff or Error states.
Example:
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system kube-dns-66bff467f8-abcde 3/3 Running 0 10d
kube-system coredns-7444b7cb8c-xyz12 1/1 Running 0 10d
...
3.2. Check Kubernetes Services
Ensure that necessary Kubernetes services are up and running.
kubectl get services --all-namespaces
- Check:
- Services like
kube-dns, kube-proxy, and others should be present and have appropriate ClusterIP or ExternalIP addresses.
Step 4: Deploy a Test Application
Deploying a simple application will help verify that the cluster can schedule pods, expose services, and handle networking correctly.
4.1. Create a Deployment
Deploy the hello-world application using a sample image.
kubectl create deployment hello-world --image=gcr.io/google-samples/hello-app:1.0
- Expected Output:
- A confirmation message indicating that a deployment named
hello-world was created.
4.2. Expose the Deployment as a Service
Expose the deployment to make it accessible within the cluster and externally if needed.
kubectl expose deployment hello-world --type=NodePort --port=8080
- Explanation:
--type=NodePort exposes the service on a port on each node in the cluster.
--port=8080 sets the port that the service will listen on.
4.3. Verify the Deployment and Service
Check that the pods are running and the service is correctly set up.
kubectl get deployments
kubectl get pods
kubectl get services
- Expected Output:
- Deployment
hello-world should have the desired number of replicas.
- Pods should be in the
Running state.
- Service
hello-world should have a NodePort assigned (e.g., 30007).
Example:
NAME READY UP-TO-DATE AVAILABLE AGE
hello-world 1/1 1 1 5m
NAME READY STATUS RESTARTS AGE
hello-world-5d6f5b8d7b-abcde 1/1 Running 0 5m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-world NodePort 10.96.0.1 <none> 8080:30007/TCP 5m
Step 5: Access the Test Application
5.1. Determine the Node’s IP Address
Find the IP address of your Ubuntu server where Kubernetes is running.
ip addr show
- Look for: The IP address associated with your primary network interface (e.g.,
eth0, ens33).
5.2. Access the Application via Browser or curl
Use the node's IP address and the assigned NodePort to access the application.
Using a Web Browser:
- Visit
http://<Node-IP>:<NodePort>
- Example:
http://192.168.1.100:30007
Using curl:
curl http://<Node-IP>:<NodePort>
- Expected Output:
- A "Hello, World" message or similar response from the test application.
Example:
Hello, world!
Step 6: Validate Networking Within the Cluster
Ensure that pods can communicate with each other and that networking components are functioning correctly.
6.1. Deploy Additional Test Pods
Deploy a simple busybox pod to use for network testing.
kubectl run -it --rm --restart=Never busybox --image=busybox:1.28 -- sh
- Inside the busybox shell, test connectivity:
# Replace <hello-world-pod-ip> with the actual Pod IP
nslookup hello-world
wget -qO- http://hello-world:8080
- Expected Output:
- Successful DNS resolution of
hello-world.
- Receipt of the "Hello, World" message.
Exit the shell:
exit
6.2. Test External Connectivity
If your cluster is set up to allow external traffic, ensure that external services can reach the cluster.
- Example: Accessing the test application from an external machine using the node’s IP and
NodePort.
Step 7: Inspect Logs and Monitor Cluster Health
7.1. Check Logs of System Pods
Examine logs for critical system components to identify any underlying issues.
kubectl logs <pod-name> -n kube-system
- Replace
<pod-name> with the name of the pod you want to inspect (e.g., coredns-7444b7cb8c-xyz12).
Example:
kubectl logs coredns-7444b7cb8c-xyz12 -n kube-system
- Check for: Errors or warnings that might indicate problems with DNS resolution or other critical services.
7.2. Monitor Resource Usage
Optionally, install and use metrics-server or similar tools to monitor resource usage within the cluster.
Install Metrics Server:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Check Metrics:
kubectl top nodes
kubectl top pods --all-namespaces
- Ensure: Resource usage is within expected limits and there are no pods consuming excessive resources unnecessarily.
Step 8: Cleanup Test Deployments (Optional)
After assessment, you may want to remove the test deployment and service.
kubectl delete service hello-world
kubectl delete deployment hello-world
Additional Tips
By following the above steps, you should be able to comprehensively assess whether your Kubernetes installation is functioning correctly on your Ubuntu Server. If you encounter any issues during the assessment, feel free to provide the error messages or symptoms, and I can assist you further in troubleshooting.