The Kubernetes command-line tool, kubectl is used to run commands against Kubernetes clusters. You’ll use kubectl to inspect and manage your service’s cluster resources and view logs. Some commonly used commands for retrieving information about a Kubernetes cluster are as follows: kubectl get shows information about the specified API object. kubectl describe gives more detail […]
Kubernetes
Kubernetes Command Line Reference (Cheatsheet)
Creating Objects Create resource: $ kubectl apply -f ./<file_name>.yaml Create from multiple files: $ kubectl apply -f ./<file_name_1>.yaml -f ./<file_name_2>.yaml Create all files in directory: $ kubectl apply -f ./<directory_name> Create from url: $ kubectl apply -f https://<url> Create pod: $ kubectl run <pod_name> –image <image_name> Create pod, then expose it as service: $ kubectl […]
“Error: Could Not Find A Ready Tiller Pod” – helm error
The Problem Getting “Error: could not find a ready tiller pod” error when trying various helm commands. > helm version Client: &version.Version{SemVer:”v2.14.3″, GitCommit:”0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085″, GitTreeState:”clean”} Error: could not find a ready tiller pod The Solution This error is caused due to wrong configuration or version mismatch. Follow the procedure to install helm and tiller using the […]
How to schedule master node running pod/service as worker node
Question: How to Schedule Master Node to Run Pod Workloads Like the Worker Node? By default, only the worker node can run the pod workloads and the master is only responsible for the scheduling and configuration. $ kubectl get nodes -o json | jq .items[].spec.taints [ { “effect”: “NoSchedule”, “key”: “node-role.kubernetes.io/master” } ] $ kubectl […]
How To Access Kubernetes Dashboard Externally
Following is an alternative workaround to access Dashboard externally. 1. kubernetes-dashboard is a service file which provides dash-board functionality, to edit this we need to edit dashboard service and change service “type” from ClusterIP to NodePort: [root@kubeXXXX]# kubectl -n kube-system edit service kubernetes-dashboard # Please edit the object below. Lines beginning with a ‘#’ will […]
New User Failed Run Kubectl with Error “The connection to the server xxx.xxx.xxx was refused – did you specify the right host or port?”
The Problem When run kubectl from a new created user, failed with error: The connection to the server xxx.xxx.xxx was refused – did you specify the right host or port? The Solution A newly created user has no KUBECONFIG configured. Setup kubernetes configuration for the new user: # mkdir -p $HOME/.kube # sudo cp -i […]
How to schedule master node running pod/service as a worker node
Question: How can I schedule master node running pod/service as worker node? By deafult, only worker node could run the pod, master only response for the scheduler/configuration. $ kubectl get nodes -o json | jq .items[].spec.taints [ { “effect”: “NoSchedule”, “key”: “node-role.kubernetes.io/master” } ] $ kubectl get nodes -o json | grep master “node-role.kubernetes.io/master”: “” […]
Endpoint is not Created for Service in Kubernetes
The Problem Endpoints shows ‘none’: $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.yy.0.1 <none> 443/TCP 9d test ClusterIP 10.xx.97.97 <none> 6379/TCP 21s $ kubectl describe svc test Name: test Namespace: default Labels: <none> Annotations: kubectl.kubernetes.io/last-applied-configuration: {“apiVersion”:”v1″,”kind”:”Service”,”metadata”:{“annotations”:{},”name”:”test”,”namespace”:”default”},”spec”:{“clusterIP”:”10.xx.97.97″,”… Selector: app=test Type: ClusterIP IP: 10.xx.97.97 Port: <unset> 6379/TCP TargetPort: 6379/TCP Endpoints: <none> Session […]
Troubleshooting kubectl Error: The connection to the server x.x.x.x:6443 was refused – did you specify the right host or port?
This document describes steps to troubleshoot kubectl error: The connection to the server x.x.x.x:6443 was refused – did you specify the right host or port? 1. The kubectl should be executed on the Master Node. 2. Current user must have Kubernetes cluster configuration environment variable (Details of how to are listed under section Preparing to […]