🏷️ Troubleshoot cluster component

🏷️ Troubleshoot cluster component#

Check k8s components status.#

On a control-plane.

 typeset -A KUBE
ᐅ KUBE[kubelet]="http://127.0.0.1:10248/healthz" KUBE[apiserver]="https://192.168.94.73:6443/livez" KUBE[controller-manager]="https://127.0.0.1:10257/healthz" KUBE[scheduler]="https://127.0.0.1:10259/livez" for i in "${!KUBE[@]}"
do
  echo "$i" "$(curl -sk ${KUBE[$i]})"
done | \
awk 'BEGIN{
  format="%-20s %s\n"
  printf format, "components", "status"
  printf format, "---", "---"
}{
  printf format, $1, $2
}'

Get object description#

 k explain svc.spec.clusterIP
KIND:       Service
VERSION:    v1

FIELD: clusterIP <string>


DESCRIPTION:
    clusterIP is the IP address of the service and is usually assigned randomly.
    If an address is specified manually, is in-range (as per system
    configuration), and is not in use, it will be allocated to the service;
    otherwise creation of the service will fail. This field may not be changed
    through updates unless the type field is also being changed to ExternalName
    (which requires this field to be blank) or the type field is being changed
    from ExternalName (in which case this field may optionally be specified, as
    describe above).  Valid values are "None", empty string (""), or a valid IP
    address. Setting this to "None" makes a "headless service" (no virtual IP),
    which is useful when direct endpoint connections are preferred and proxying
    is not required.  Only applies to types ClusterIP, NodePort, and
    LoadBalancer. If this field is specified when creating a Service of type
    ExternalName, creation will fail. This field will be wiped when updating a
    Service to type ExternalName. More info:
    https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
k explain svc.spec --recursive=true
KIND:       Service
VERSION:    v1

FIELD: spec <ServiceSpec>


DESCRIPTION:
    Spec defines the behavior of a service.
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
    ServiceSpec describes the attributes that a user creates on a service.

FIELDS:
  allocateLoadBalancerNodePorts <boolean>
  clusterIP     <string>
  clusterIPs    <[]string>
  externalIPs   <[]string>
  externalName  <string>
  externalTrafficPolicy <string>
  enum: Cluster, Local
  healthCheckNodePort   <integer>
  internalTrafficPolicy <string>
  enum: Cluster, Local
  ipFamilies    <[]string>
  ipFamilyPolicy        <string>
  enum: PreferDualStack, RequireDualStack, SingleStack
  loadBalancerClass     <string>
  loadBalancerIP        <string>
  loadBalancerSourceRanges      <[]string>
  ports <[]ServicePort>
    appProtocol <string>
    name        <string>
    nodePort    <integer>
    port        <integer> -required-
    protocol    <string>
    enum: SCTP, TCP, UDP
    targetPort  <IntOrString>
  publishNotReadyAddresses      <boolean>
  selector      <map[string]string>
  sessionAffinity       <string>
  enum: ClientIP, None
  sessionAffinityConfig <SessionAffinityConfig>
    clientIP    <ClientIPConfig>
      timeoutSeconds    <integer>
  trafficDistribution   <string>
  type  <string>
  enum: ClusterIP, ExternalName, LoadBalancer, NodePort