[{"data":1,"prerenderedAt":1240},["ShallowReactive",2],{"page-en-\u002Fblog\u002Fkubectl-commands":3},{"id":4,"title":5,"body":6,"date":1227,"description":1228,"extension":1229,"meta":1230,"navigation":621,"path":1231,"seo":1232,"stem":1233,"tags":1234,"translation":1238,"__hash__":1239},"pages_en\u002Fen\u002Fblog\u002Fkubectl-commands.md","Frequently Used kubectl Commands",{"type":7,"value":8,"toc":1214},"minimark",[9,14,22,33,37,40,135,139,285,314,318,378,401,405,521,524,528,714,723,727,849,855,859,950,956,960,1047,1051,1130,1133,1166,1170,1210],[10,11,13],"h2",{"id":12},"introduction","Introduction",[15,16,17,21],"p",{},[18,19,20],"code",{},"kubectl"," is the command-line tool for talking to a Kubernetes cluster. From listing pods to updating deployments, reading logs to opening a shell in a container, nearly all daily work comes down to a few dozen commands. This post collects them in order of use.",[15,23,24,25,28,29,32],{},"The examples use ",[18,26,27],{},"api"," as the deployment name and ",[18,30,31],{},"prod"," as the namespace.",[10,34,36],{"id":35},"_1-cluster-and-context","1. Cluster and context",[15,38,39],{},"If you work with more than one cluster, the first thing to know is which one you're connected to.",[41,42,47],"pre",{"className":43,"code":44,"language":45,"meta":46,"style":46},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","kubectl version                        # client and server version\nkubectl cluster-info                   # API server address\nkubectl config get-contexts            # all configured contexts\nkubectl config current-context         # active context\nkubectl config use-context prod-cluster\nkubectl config set-context --current --namespace=prod   # default namespace\n","bash","",[18,48,49,65,76,90,103,116],{"__ignoreMap":46},[50,51,54,57,61],"span",{"class":52,"line":53},"line",1,[50,55,20],{"class":56},"sBMFI",[50,58,60],{"class":59},"sfazB"," version",[50,62,64],{"class":63},"sHwdD","                        # client and server version\n",[50,66,68,70,73],{"class":52,"line":67},2,[50,69,20],{"class":56},[50,71,72],{"class":59}," cluster-info",[50,74,75],{"class":63},"                   # API server address\n",[50,77,79,81,84,87],{"class":52,"line":78},3,[50,80,20],{"class":56},[50,82,83],{"class":59}," config",[50,85,86],{"class":59}," get-contexts",[50,88,89],{"class":63},"            # all configured contexts\n",[50,91,93,95,97,100],{"class":52,"line":92},4,[50,94,20],{"class":56},[50,96,83],{"class":59},[50,98,99],{"class":59}," current-context",[50,101,102],{"class":63},"         # active context\n",[50,104,106,108,110,113],{"class":52,"line":105},5,[50,107,20],{"class":56},[50,109,83],{"class":59},[50,111,112],{"class":59}," use-context",[50,114,115],{"class":59}," prod-cluster\n",[50,117,119,121,123,126,129,132],{"class":52,"line":118},6,[50,120,20],{"class":56},[50,122,83],{"class":59},[50,124,125],{"class":59}," set-context",[50,127,128],{"class":59}," --current",[50,130,131],{"class":59}," --namespace=prod",[50,133,134],{"class":63},"   # default namespace\n",[10,136,138],{"id":137},"_2-listing-resources","2. Listing resources",[41,140,142],{"className":43,"code":141,"language":45,"meta":46,"style":46},"kubectl get pods                       # pods in the active namespace\nkubectl get pods -n prod               # a specific namespace\nkubectl get pods -A                    # all namespaces\nkubectl get pods -o wide               # with node and IP\nkubectl get pods -l app=api            # filter by label\nkubectl get pods -w                    # watch changes live\nkubectl get deploy,svc,ingress         # several resource types\nkubectl get all -n prod\nkubectl get pod api-7d9f-x2k -o yaml   # full resource definition\n",[18,143,144,157,174,188,205,222,236,249,264],{"__ignoreMap":46},[50,145,146,148,151,154],{"class":52,"line":53},[50,147,20],{"class":56},[50,149,150],{"class":59}," get",[50,152,153],{"class":59}," pods",[50,155,156],{"class":63},"                       # pods in the active namespace\n",[50,158,159,161,163,165,168,171],{"class":52,"line":67},[50,160,20],{"class":56},[50,162,150],{"class":59},[50,164,153],{"class":59},[50,166,167],{"class":59}," -n",[50,169,170],{"class":59}," prod",[50,172,173],{"class":63},"               # a specific namespace\n",[50,175,176,178,180,182,185],{"class":52,"line":78},[50,177,20],{"class":56},[50,179,150],{"class":59},[50,181,153],{"class":59},[50,183,184],{"class":59}," -A",[50,186,187],{"class":63},"                    # all namespaces\n",[50,189,190,192,194,196,199,202],{"class":52,"line":92},[50,191,20],{"class":56},[50,193,150],{"class":59},[50,195,153],{"class":59},[50,197,198],{"class":59}," -o",[50,200,201],{"class":59}," wide",[50,203,204],{"class":63},"               # with node and IP\n",[50,206,207,209,211,213,216,219],{"class":52,"line":105},[50,208,20],{"class":56},[50,210,150],{"class":59},[50,212,153],{"class":59},[50,214,215],{"class":59}," -l",[50,217,218],{"class":59}," app=api",[50,220,221],{"class":63},"            # filter by label\n",[50,223,224,226,228,230,233],{"class":52,"line":118},[50,225,20],{"class":56},[50,227,150],{"class":59},[50,229,153],{"class":59},[50,231,232],{"class":59}," -w",[50,234,235],{"class":63},"                    # watch changes live\n",[50,237,239,241,243,246],{"class":52,"line":238},7,[50,240,20],{"class":56},[50,242,150],{"class":59},[50,244,245],{"class":59}," deploy,svc,ingress",[50,247,248],{"class":63},"         # several resource types\n",[50,250,252,254,256,259,261],{"class":52,"line":251},8,[50,253,20],{"class":56},[50,255,150],{"class":59},[50,257,258],{"class":59}," all",[50,260,167],{"class":59},[50,262,263],{"class":59}," prod\n",[50,265,267,269,271,274,277,279,282],{"class":52,"line":266},9,[50,268,20],{"class":56},[50,270,150],{"class":59},[50,272,273],{"class":59}," pod",[50,275,276],{"class":59}," api-7d9f-x2k",[50,278,198],{"class":59},[50,280,281],{"class":59}," yaml",[50,283,284],{"class":63},"   # full resource definition\n",[15,286,287,288,291,292,295,296,295,299,295,302,305,306,309,310,313],{},"Short names save time: ",[18,289,290],{},"po"," (pods), ",[18,293,294],{},"deploy",", ",[18,297,298],{},"svc",[18,300,301],{},"ns",[18,303,304],{},"cm"," (configmap), ",[18,307,308],{},"ing"," (ingress), ",[18,311,312],{},"no"," (nodes).",[10,315,317],{"id":316},"_3-details-and-events","3. Details and events",[41,319,321],{"className":43,"code":320,"language":45,"meta":46,"style":46},"kubectl describe pod api-7d9f-x2k      # status, events, containers\nkubectl describe deploy api\nkubectl get events -n prod --sort-by=.lastTimestamp\nkubectl explain deployment.spec.strategy   # field documentation\n",[18,322,323,337,349,365],{"__ignoreMap":46},[50,324,325,327,330,332,334],{"class":52,"line":53},[50,326,20],{"class":56},[50,328,329],{"class":59}," describe",[50,331,273],{"class":59},[50,333,276],{"class":59},[50,335,336],{"class":63},"      # status, events, containers\n",[50,338,339,341,343,346],{"class":52,"line":67},[50,340,20],{"class":56},[50,342,329],{"class":59},[50,344,345],{"class":59}," deploy",[50,347,348],{"class":59}," api\n",[50,350,351,353,355,358,360,362],{"class":52,"line":78},[50,352,20],{"class":56},[50,354,150],{"class":59},[50,356,357],{"class":59}," events",[50,359,167],{"class":59},[50,361,170],{"class":59},[50,363,364],{"class":59}," --sort-by=.lastTimestamp\n",[50,366,367,369,372,375],{"class":52,"line":92},[50,368,20],{"class":56},[50,370,371],{"class":59}," explain",[50,373,374],{"class":59}," deployment.spec.strategy",[50,376,377],{"class":63},"   # field documentation\n",[15,379,380,381,295,384,387,388,391,392,396,397,400],{},"When a pod is ",[18,382,383],{},"Pending",[18,385,386],{},"CrashLoopBackOff"," or ",[18,389,390],{},"ImagePullBackOff",", the cause is almost always in the ",[393,394,395],"strong",{},"Events"," section at the bottom of ",[18,398,399],{},"describe",".",[10,402,404],{"id":403},"_4-create-update-delete","4. Create, update, delete",[41,406,408],{"className":43,"code":407,"language":45,"meta":46,"style":46},"kubectl apply -f deployment.yaml       # create or update\nkubectl apply -f k8s\u002F                  # every manifest in a folder\nkubectl diff -f deployment.yaml        # see the diff before applying\nkubectl delete -f deployment.yaml\nkubectl delete pod api-7d9f-x2k        # the deployment starts a new one\nkubectl create deployment api --image=nginx:1.27\nkubectl create deployment api --image=nginx:1.27 --dry-run=client -o yaml > deployment.yaml\n",[18,409,410,426,440,454,466,479,495],{"__ignoreMap":46},[50,411,412,414,417,420,423],{"class":52,"line":53},[50,413,20],{"class":56},[50,415,416],{"class":59}," apply",[50,418,419],{"class":59}," -f",[50,421,422],{"class":59}," deployment.yaml",[50,424,425],{"class":63},"       # create or update\n",[50,427,428,430,432,434,437],{"class":52,"line":67},[50,429,20],{"class":56},[50,431,416],{"class":59},[50,433,419],{"class":59},[50,435,436],{"class":59}," k8s\u002F",[50,438,439],{"class":63},"                  # every manifest in a folder\n",[50,441,442,444,447,449,451],{"class":52,"line":78},[50,443,20],{"class":56},[50,445,446],{"class":59}," diff",[50,448,419],{"class":59},[50,450,422],{"class":59},[50,452,453],{"class":63},"        # see the diff before applying\n",[50,455,456,458,461,463],{"class":52,"line":92},[50,457,20],{"class":56},[50,459,460],{"class":59}," delete",[50,462,419],{"class":59},[50,464,465],{"class":59}," deployment.yaml\n",[50,467,468,470,472,474,476],{"class":52,"line":105},[50,469,20],{"class":56},[50,471,460],{"class":59},[50,473,273],{"class":59},[50,475,276],{"class":59},[50,477,478],{"class":63},"        # the deployment starts a new one\n",[50,480,481,483,486,489,492],{"class":52,"line":118},[50,482,20],{"class":56},[50,484,485],{"class":59}," create",[50,487,488],{"class":59}," deployment",[50,490,491],{"class":59}," api",[50,493,494],{"class":59}," --image=nginx:1.27\n",[50,496,497,499,501,503,505,508,511,513,515,519],{"class":52,"line":238},[50,498,20],{"class":56},[50,500,485],{"class":59},[50,502,488],{"class":59},[50,504,491],{"class":59},[50,506,507],{"class":59}," --image=nginx:1.27",[50,509,510],{"class":59}," --dry-run=client",[50,512,198],{"class":59},[50,514,281],{"class":59},[50,516,518],{"class":517},"sMK4o"," >",[50,520,465],{"class":59},[15,522,523],{},"The last command is the fastest way to get a YAML skeleton instead of writing one from scratch.",[10,525,527],{"id":526},"_5-logs-exec-and-port-forward","5. Logs, exec and port-forward",[41,529,531],{"className":43,"code":530,"language":45,"meta":46,"style":46},"kubectl logs api-7d9f-x2k              # pod logs\nkubectl logs -f api-7d9f-x2k           # follow\nkubectl logs api-7d9f-x2k -c sidecar   # a specific container in a multi-container pod\nkubectl logs api-7d9f-x2k --previous   # logs of the previous, crashed container\nkubectl logs deploy\u002Fapi --tail=100     # logs of one of the deployment's pods\nkubectl logs -l app=api --since=1h\n\nkubectl exec -it api-7d9f-x2k -- sh    # open a shell in the container\nkubectl exec api-7d9f-x2k -- env       # run a single command\n\nkubectl port-forward svc\u002Fapi 8080:80   # localhost:8080 → service port 80\nkubectl port-forward pod\u002Fapi-7d9f-x2k 5005:5005\n\nkubectl cp api-7d9f-x2k:\u002Fapp\u002Flogs\u002Fapp.log .\u002Fapp.log\n",[18,532,533,545,558,575,589,604,617,623,644,660,665,682,695,700],{"__ignoreMap":46},[50,534,535,537,540,542],{"class":52,"line":53},[50,536,20],{"class":56},[50,538,539],{"class":59}," logs",[50,541,276],{"class":59},[50,543,544],{"class":63},"              # pod logs\n",[50,546,547,549,551,553,555],{"class":52,"line":67},[50,548,20],{"class":56},[50,550,539],{"class":59},[50,552,419],{"class":59},[50,554,276],{"class":59},[50,556,557],{"class":63},"           # follow\n",[50,559,560,562,564,566,569,572],{"class":52,"line":78},[50,561,20],{"class":56},[50,563,539],{"class":59},[50,565,276],{"class":59},[50,567,568],{"class":59}," -c",[50,570,571],{"class":59}," sidecar",[50,573,574],{"class":63},"   # a specific container in a multi-container pod\n",[50,576,577,579,581,583,586],{"class":52,"line":92},[50,578,20],{"class":56},[50,580,539],{"class":59},[50,582,276],{"class":59},[50,584,585],{"class":59}," --previous",[50,587,588],{"class":63},"   # logs of the previous, crashed container\n",[50,590,591,593,595,598,601],{"class":52,"line":105},[50,592,20],{"class":56},[50,594,539],{"class":59},[50,596,597],{"class":59}," deploy\u002Fapi",[50,599,600],{"class":59}," --tail=100",[50,602,603],{"class":63},"     # logs of one of the deployment's pods\n",[50,605,606,608,610,612,614],{"class":52,"line":118},[50,607,20],{"class":56},[50,609,539],{"class":59},[50,611,215],{"class":59},[50,613,218],{"class":59},[50,615,616],{"class":59}," --since=1h\n",[50,618,619],{"class":52,"line":238},[50,620,622],{"emptyLinePlaceholder":621},true,"\n",[50,624,625,627,630,633,635,638,641],{"class":52,"line":251},[50,626,20],{"class":56},[50,628,629],{"class":59}," exec",[50,631,632],{"class":59}," -it",[50,634,276],{"class":59},[50,636,637],{"class":59}," --",[50,639,640],{"class":59}," sh",[50,642,643],{"class":63},"    # open a shell in the container\n",[50,645,646,648,650,652,654,657],{"class":52,"line":266},[50,647,20],{"class":56},[50,649,629],{"class":59},[50,651,276],{"class":59},[50,653,637],{"class":59},[50,655,656],{"class":59}," env",[50,658,659],{"class":63},"       # run a single command\n",[50,661,663],{"class":52,"line":662},10,[50,664,622],{"emptyLinePlaceholder":621},[50,666,668,670,673,676,679],{"class":52,"line":667},11,[50,669,20],{"class":56},[50,671,672],{"class":59}," port-forward",[50,674,675],{"class":59}," svc\u002Fapi",[50,677,678],{"class":59}," 8080:80",[50,680,681],{"class":63},"   # localhost:8080 → service port 80\n",[50,683,685,687,689,692],{"class":52,"line":684},12,[50,686,20],{"class":56},[50,688,672],{"class":59},[50,690,691],{"class":59}," pod\u002Fapi-7d9f-x2k",[50,693,694],{"class":59}," 5005:5005\n",[50,696,698],{"class":52,"line":697},13,[50,699,622],{"emptyLinePlaceholder":621},[50,701,703,705,708,711],{"class":52,"line":702},14,[50,704,20],{"class":56},[50,706,707],{"class":59}," cp",[50,709,710],{"class":59}," api-7d9f-x2k:\u002Fapp\u002Flogs\u002Fapp.log",[50,712,713],{"class":59}," .\u002Fapp.log\n",[15,715,716,719,720,722],{},[18,717,718],{},"--previous"," is the only way to see why a pod in ",[18,721,386],{}," crashed.",[10,724,726],{"id":725},"_6-managing-deployments","6. Managing deployments",[41,728,730],{"className":43,"code":729,"language":45,"meta":46,"style":46},"kubectl scale deploy api --replicas=5\nkubectl set image deploy\u002Fapi api=registry.local\u002Fapi:1.4.2\nkubectl rollout status deploy\u002Fapi      # is the update finished?\nkubectl rollout history deploy\u002Fapi\nkubectl rollout undo deploy\u002Fapi        # roll back to the previous revision\nkubectl rollout undo deploy\u002Fapi --to-revision=3\nkubectl rollout restart deploy\u002Fapi     # restart all pods one by one\nkubectl autoscale deploy api --min=2 --max=10 --cpu-percent=70\n",[18,731,732,746,761,776,788,802,815,829],{"__ignoreMap":46},[50,733,734,736,739,741,743],{"class":52,"line":53},[50,735,20],{"class":56},[50,737,738],{"class":59}," scale",[50,740,345],{"class":59},[50,742,491],{"class":59},[50,744,745],{"class":59}," --replicas=5\n",[50,747,748,750,753,756,758],{"class":52,"line":67},[50,749,20],{"class":56},[50,751,752],{"class":59}," set",[50,754,755],{"class":59}," image",[50,757,597],{"class":59},[50,759,760],{"class":59}," api=registry.local\u002Fapi:1.4.2\n",[50,762,763,765,768,771,773],{"class":52,"line":78},[50,764,20],{"class":56},[50,766,767],{"class":59}," rollout",[50,769,770],{"class":59}," status",[50,772,597],{"class":59},[50,774,775],{"class":63},"      # is the update finished?\n",[50,777,778,780,782,785],{"class":52,"line":92},[50,779,20],{"class":56},[50,781,767],{"class":59},[50,783,784],{"class":59}," history",[50,786,787],{"class":59}," deploy\u002Fapi\n",[50,789,790,792,794,797,799],{"class":52,"line":105},[50,791,20],{"class":56},[50,793,767],{"class":59},[50,795,796],{"class":59}," undo",[50,798,597],{"class":59},[50,800,801],{"class":63},"        # roll back to the previous revision\n",[50,803,804,806,808,810,812],{"class":52,"line":118},[50,805,20],{"class":56},[50,807,767],{"class":59},[50,809,796],{"class":59},[50,811,597],{"class":59},[50,813,814],{"class":59}," --to-revision=3\n",[50,816,817,819,821,824,826],{"class":52,"line":238},[50,818,20],{"class":56},[50,820,767],{"class":59},[50,822,823],{"class":59}," restart",[50,825,597],{"class":59},[50,827,828],{"class":63},"     # restart all pods one by one\n",[50,830,831,833,836,838,840,843,846],{"class":52,"line":251},[50,832,20],{"class":56},[50,834,835],{"class":59}," autoscale",[50,837,345],{"class":59},[50,839,491],{"class":59},[50,841,842],{"class":59}," --min=2",[50,844,845],{"class":59}," --max=10",[50,847,848],{"class":59}," --cpu-percent=70\n",[15,850,851,854],{},[18,852,853],{},"rollout restart"," is the cleanest way to make pods pick up a changed ConfigMap or Secret.",[10,856,858],{"id":857},"_7-configmaps-and-secrets","7. ConfigMaps and Secrets",[41,860,862],{"className":43,"code":861,"language":45,"meta":46,"style":46},"kubectl create configmap api-config --from-file=application.yaml\nkubectl create configmap api-config --from-literal=LOG_LEVEL=info\nkubectl create secret generic db-secret --from-literal=password='S3cret!'\nkubectl get secret db-secret -o jsonpath='{.data.password}' | base64 -d\n",[18,863,864,879,892,919],{"__ignoreMap":46},[50,865,866,868,870,873,876],{"class":52,"line":53},[50,867,20],{"class":56},[50,869,485],{"class":59},[50,871,872],{"class":59}," configmap",[50,874,875],{"class":59}," api-config",[50,877,878],{"class":59}," --from-file=application.yaml\n",[50,880,881,883,885,887,889],{"class":52,"line":67},[50,882,20],{"class":56},[50,884,485],{"class":59},[50,886,872],{"class":59},[50,888,875],{"class":59},[50,890,891],{"class":59}," --from-literal=LOG_LEVEL=info\n",[50,893,894,896,898,901,904,907,910,913,916],{"class":52,"line":78},[50,895,20],{"class":56},[50,897,485],{"class":59},[50,899,900],{"class":59}," secret",[50,902,903],{"class":59}," generic",[50,905,906],{"class":59}," db-secret",[50,908,909],{"class":59}," --from-literal=password=",[50,911,912],{"class":517},"'",[50,914,915],{"class":59},"S3cret!",[50,917,918],{"class":517},"'\n",[50,920,921,923,925,927,929,931,934,936,939,941,944,947],{"class":52,"line":92},[50,922,20],{"class":56},[50,924,150],{"class":59},[50,926,900],{"class":59},[50,928,906],{"class":59},[50,930,198],{"class":59},[50,932,933],{"class":59}," jsonpath=",[50,935,912],{"class":517},[50,937,938],{"class":59},"{.data.password}",[50,940,912],{"class":517},[50,942,943],{"class":517}," |",[50,945,946],{"class":56}," base64",[50,948,949],{"class":59}," -d\n",[951,952,953],"blockquote",{},[15,954,955],{},"Secret values are only base64-encoded, not encrypted. Don't commit plain Secret manifests; use something like Sealed Secrets or External Secrets.",[10,957,959],{"id":958},"_8-resource-usage-and-nodes","8. Resource usage and nodes",[41,961,963],{"className":43,"code":962,"language":45,"meta":46,"style":46},"kubectl top nodes                      # requires metrics-server\nkubectl top pods -n prod --sort-by=memory\nkubectl get nodes -o wide\nkubectl cordon node-1                  # stop scheduling new pods\nkubectl drain node-1 --ignore-daemonsets --delete-emptydir-data   # empty it for maintenance\nkubectl uncordon node-1\n",[18,964,965,978,993,1006,1019,1037],{"__ignoreMap":46},[50,966,967,969,972,975],{"class":52,"line":53},[50,968,20],{"class":56},[50,970,971],{"class":59}," top",[50,973,974],{"class":59}," nodes",[50,976,977],{"class":63},"                      # requires metrics-server\n",[50,979,980,982,984,986,988,990],{"class":52,"line":67},[50,981,20],{"class":56},[50,983,971],{"class":59},[50,985,153],{"class":59},[50,987,167],{"class":59},[50,989,170],{"class":59},[50,991,992],{"class":59}," --sort-by=memory\n",[50,994,995,997,999,1001,1003],{"class":52,"line":78},[50,996,20],{"class":56},[50,998,150],{"class":59},[50,1000,974],{"class":59},[50,1002,198],{"class":59},[50,1004,1005],{"class":59}," wide\n",[50,1007,1008,1010,1013,1016],{"class":52,"line":92},[50,1009,20],{"class":56},[50,1011,1012],{"class":59}," cordon",[50,1014,1015],{"class":59}," node-1",[50,1017,1018],{"class":63},"                  # stop scheduling new pods\n",[50,1020,1021,1023,1026,1028,1031,1034],{"class":52,"line":105},[50,1022,20],{"class":56},[50,1024,1025],{"class":59}," drain",[50,1027,1015],{"class":59},[50,1029,1030],{"class":59}," --ignore-daemonsets",[50,1032,1033],{"class":59}," --delete-emptydir-data",[50,1035,1036],{"class":63},"   # empty it for maintenance\n",[50,1038,1039,1041,1044],{"class":52,"line":118},[50,1040,20],{"class":56},[50,1042,1043],{"class":59}," uncordon",[50,1045,1046],{"class":59}," node-1\n",[10,1048,1050],{"id":1049},"_9-troubleshooting-summary","9. Troubleshooting summary",[1052,1053,1054,1067],"table",{},[1055,1056,1057],"thead",{},[1058,1059,1060,1064],"tr",{},[1061,1062,1063],"th",{},"Situation",[1061,1065,1066],{},"Where to look",[1068,1069,1070,1083,1095,1107,1119],"tbody",{},[1058,1071,1072,1077],{},[1073,1074,1075],"td",{},[18,1076,383],{},[1073,1078,1079,1082],{},[18,1080,1081],{},"kubectl describe pod"," → Events: insufficient resources, PVC, node selector",[1058,1084,1085,1089],{},[1073,1086,1087],{},[18,1088,390],{},[1073,1090,1091,1092],{},"Image name\u002Ftag, registry access, ",[18,1093,1094],{},"imagePullSecrets",[1058,1096,1097,1101],{},[1073,1098,1099],{},[18,1100,386],{},[1073,1102,1103,1106],{},[18,1104,1105],{},"kubectl logs --previous",", liveness probe, missing env",[1058,1108,1109,1114],{},[1073,1110,1111],{},[18,1112,1113],{},"OOMKilled",[1073,1115,1116,1118],{},[18,1117,399],{}," → Last State; raise the memory limit or find the leak",[1058,1120,1121,1124],{},[1073,1122,1123],{},"Service unreachable",[1073,1125,1126,1129],{},[18,1127,1128],{},"kubectl get endpoints api"," — does the label selector match?",[15,1131,1132],{},"A throwaway debug pod also solves most network issues quickly:",[41,1134,1136],{"className":43,"code":1135,"language":45,"meta":46,"style":46},"kubectl run debug --rm -it --image=busybox -- sh\n# inside: nslookup api.prod.svc.cluster.local, wget -qO- http:\u002F\u002Fapi\n",[18,1137,1138,1161],{"__ignoreMap":46},[50,1139,1140,1142,1145,1148,1151,1153,1156,1158],{"class":52,"line":53},[50,1141,20],{"class":56},[50,1143,1144],{"class":59}," run",[50,1146,1147],{"class":59}," debug",[50,1149,1150],{"class":59}," --rm",[50,1152,632],{"class":59},[50,1154,1155],{"class":59}," --image=busybox",[50,1157,637],{"class":59},[50,1159,1160],{"class":59}," sh\n",[50,1162,1163],{"class":52,"line":67},[50,1164,1165],{"class":63},"# inside: nslookup api.prod.svc.cluster.local, wget -qO- http:\u002F\u002Fapi\n",[10,1167,1169],{"id":1168},"conclusion","Conclusion",[15,1171,1172,1173,295,1176,295,1178,295,1181,295,1184,1187,1188,1191,1192,1194,1195,1197,1198,1201,1202,1205,1206,1209],{},"Most day-to-day Kubernetes work comes down to ",[18,1174,1175],{},"get",[18,1177,399],{},[18,1179,1180],{},"logs",[18,1182,1183],{},"exec",[18,1185,1186],{},"apply"," and ",[18,1189,1190],{},"rollout",". When something breaks, the order is always the same: see the state with ",[18,1193,1175],{},", read the events with ",[18,1196,399],{},", and check what the app says with ",[18,1199,1200],{},"logs --previous",". Adding ",[18,1203,1204],{},"alias k=kubectl"," and shell completion (",[18,1207,1208],{},"source \u003C(kubectl completion bash)",") also saves hundreds of keystrokes a day.",[1211,1212,1213],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}",{"title":46,"searchDepth":67,"depth":67,"links":1215},[1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226],{"id":12,"depth":67,"text":13},{"id":35,"depth":67,"text":36},{"id":137,"depth":67,"text":138},{"id":316,"depth":67,"text":317},{"id":403,"depth":67,"text":404},{"id":526,"depth":67,"text":527},{"id":725,"depth":67,"text":726},{"id":857,"depth":67,"text":858},{"id":958,"depth":67,"text":959},{"id":1049,"depth":67,"text":1050},{"id":1168,"depth":67,"text":1169},"2026-10-26","The kubectl commands that day-to-day Kubernetes work runs on — contexts, pods, deployments, logs, exec, port-forward, rollouts and troubleshooting.","md",{},"\u002Fen\u002Fblog\u002Fkubectl-commands",{"title":5,"description":1228},"en\u002Fblog\u002Fkubectl-commands",[1235,1236,1237],"kubernetes","devops","guide","\u002Fblog\u002Fkubectl-commands","eVxFUALjznfG6E0p9GOZnrhqreBcUs-cSWsGr2U7Jgo",1792969864221]