Certified Kubernetes Administrator - Introduction to the kubectl command

The objective of this post series helps you for taking the Certified Kubernetes Administrator (CKA) exam using Kubernetes Official Documentation. You don't need to install  Kubernetes  Cluster for the test that we performed on these posts. You can practice a lot with kubectl API using Katacoda.

 

Overview Of kubectl Command

Kubectl is a command-line interface for running commands against Kubernetes clusters. You can manage your apps and cluster and cluster resources by kubectl command. If you have already installed Kubernetes Cluster and you want to use kubectl command to manage it then check this link to install and configure kubectl command. But at this post, I will basically describe how to use it over Katacoda.

Kubectl commands use Kubeconfigfile to store Kubernetes cluster information. Basically this config file stores every information that you need to connect and run commands against the Kubernetes cluster. I want to add some information about the Kubeconfig file that helps you to understand how it works. 

Kubeconfig YAML file has three objects that Clusters, Contexts, Users.

  • Clusters: This is the object that you will define your cluster information like production, test, disaster, etc. 
  • Users: User information that will be used to manage the resources.
  • Contexts: A context is a group of access parameters. Each context contains a Kubernetes cluster, a user, and a namespace. It's important that namespaces parameters must be defined in contexts.

Basic kubeconfigfile example;


apiVersion: v1
kind: Config

clusters:
- name: Production
  cluster:
    certificate-authority: /etc/kubernetes/pki/ca.crt
    server: https://172.17.0.35:6443

contexts:
- name: admin@Production
  context:
    cluster: Production
    user: admin
    namespace: Billing

users:
- name: admin
  user:
    client-certificate: /etc/kubernetes/pki/users/test-user/test-user.crt
    client-key: /etc/kubernetes/pki/users/test-user/test-user.key
current-context: admin@Production

 

You can get this information from config file located under ".kube" directory and also with kubectl command.

 

#cat ~/.kube/config

OR:

#kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://172.17.0.35:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

 

Time to test your skills. Use  Katacoda and find out the answers.

Question 1:  How to get current-context and configuration?

#kubectl config current-context
kubernetes-admin@kubernetes
# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://172.17.0.35:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

Question 2:  How to change current-context?

#kubectl config get-contexts
CURRENT   NAME                          CLUSTER      AUTHINFO           NAMESPACE
*         kubernetes-admin@kubernetes   kubernetes   kubernetes-admin

#kubectl  config  use-context kubernetes-admin@kubernetes
Switched to context "kubernetes-admin@kubernetes".

Question 3:  How to get Kubernetes cluster information?

#kubectl  cluster-info
Kubernetes master is running at https://172.17.0.11:8443
KubeDNS is running at https://172.17.0.11:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

#kubectl  version 
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:12:17Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"} 

-- To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. 
#kubectl cluster-info dump

Question 4:  How to get running node information?

-- To further information about node and running software versions.
#kubectl get nodes -o yaml
#kubectl  get  node -o wide
NAME       STATUS   ROLES    AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
minikube   Ready    master   23m   v1.17.0   172.17.0.11   <none>        Ubuntu 18.04.3 LTS   4.15.0-72-generic   docker://18.9.7

Question 5:  How to get running pods?

#kubectl get pods --all-namespaces

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

204 Total Posts
Follow Me

36 Comments

  1. Generic! Smile more. people what is in cialis See you in New Year USA 2020 Buy Cialis cheap

  2. A próxima lanço é controle químico do envolvente.

  3. Amazing! Its really amazing post, I have got much clear idea concerning from this article.

  4. I have been surfing online more thjan 3 hours as of late, but I never discovered any attention-grabbing article like yours. It's beautiful price enough for me. In my view, if all web owners and bloggers made excellent content material aas you probably did, the internet can be much moore useful than ever before.

  5. Have you ever thought about including a little bit ore than just your articles? I mean, what youu sayy is valuable and all. Nevertheless imagone iff you added some great visuas oor video clips to give your posts more, "pop"! Your content iis excellent but with pics andd clips, this skte could definitely be one off thhe most beneficial in itss field. Amazing blog!

  6. Good day! Do you know if they make any pluginns to help with SEO? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good gains. If you know of any please share. Many thanks!

  7. Hello. And Bye. http://www.viagra-online-withoutprescription.org/ viagra-online-withoutprescription.org

  8. Hello. And Bye. http://www.viagra-online-withoutprescription.org/ viagra-online-withoutprescription.org

  9. Hello. And Bye. http://www.viagra-online-withoutprescription.org/ viagra-online-withoutprescription.org viagra online

  10. It is appropriate time to make a few plans for the longer term and it is time to be happy. I've read this submit and if I may I wish to counsel you few interesting things or tips. Perhaps you could write next articles relating to this article. I wish to read even more issues about it! research paper writing service https://essaywritingtld.com/

  11. This piece of writing is really a good one it assists new web viewers, who are wishing for blogging. write my paper for me https://essayhelpforall.com/

  12. Thanks , I have recently been looking for information approximately this subject for ages and yours is the best I have came upon so far. However, what about the conclusion? Are you positive in regards to the supply? writing pages https://essayservicesall.com/

  13. Hey just wanted to give you a quick heads up. The text in your content seem to be running off the screen in Opera. I'm not sure if this is a formatting issue or something to do with web browser compatibility but I figured I'd post to let you know. The design and style look great though! Hope you get the problem fixed soon. Kudos write an essay https://allbestessaywritingservice.com/

  14. I know this if off topic but I'm looking into starting my own blog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny? I'm not very web savvy so I'm not 100% certain. Any tips or advice would be greatly appreciated. Thanks buy an essay https://essaywritingusauk.com/

  15. Good day! This post couldn't be written any better! Reading this post reminds me of my old room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Thanks for sharing! writing an essay https://essaywritingtld.com/

  16. I'm really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it's rare to see a great blog like this one these days. write my papers https://onlineessayforyou.com/

  17. Pretty! This was a really wonderful article. Thanks for providing these details. college persuasive essay https://buyessayscc.com/

  18. I am regular visitor, how are you everybody? This piece of writing posted at this site is truly nice. a persuasive essay https://essayservicesall.com/

  19. I havfe read so many articles concerning the bloggwr lovers but this paragraph is really a fastidious paragraph, keep it up. write my essays https://bestessaywritingservice.info/autism-and-writing-essays.html

  20. This paragraph is in fact a nice one it helps new net users, who are wishing for blogging. college essay help https://essaymeaning5579.weebly.com/blog/cheap-essay-writing-service-at-10-eight

  21. Hi there, I enjoy reading through your article. I wanted to write a little comment to support you. argument essay https://aboutessaywriting296.blogspot.com/2020/09/psychoanalysis-on-great-gatsby-essay.html

  22. You can definitely see your enthusiasm in the articlpe you write. The sector hopes for even more passionate writeds such as you who aren't afraid to say hoow they believe. At all times go after your heart. term paper help https://allbestessaywritingservice.com

  23. Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is totally off topic but I had to tell someone! someone write my paper https://buyessayscc.com/

  24. And sexually matured in return as forewarning as orchestra cialis ed dosage Discomfort Duro Rehab Thickening-25 Fibrous Beat Can Merely Out Mr.

  25. Every weekend i used to go to see this web site, for the reason that i want enjoyment, for the reason that this this site conations actually fastidious funny data too. buy cialis online with no prescription

  26. Hi! Do you know if they make any plugins to help with Search Engine Optimization? I'm trying to get myy blog to rank foor some targeted keywords but I'm not seeing very ood gains. If you know of any please share. Thanks! write a paper https://professionalessaywritingservice.com

  27. require reckoning Elderly In for the treatment of the hospital. cheap au cialis soft I’ve needed with our CS a few data to get.

  28. Thanks for sharing your thoughts on best price cialis online. Regards https://comprarcialis5mgonline.com/marca-cialis-professional-20-mg.html buy cialis online for cheap

  29. Saved as a favorite, I like your web site! https://comprarcialis5mgonline.com/marca-cialis-professional-20-mg.html legit cialis online

  30. Heya i'm for the first time here. I came across this board and I to find It really helpful & it helped me out much. I hope to give something back and aid others such as you helped me. Buy custom college essay online https://paper-writers37.tistory.com/1

  31. We are a group of volunteers and starting a new scheme in our community. Your site provided us with valuable information to wordk on. You've done a formidable job and our entire community will be thankful to you. help me with my essay https://buyresearchpaper2692.weebly.com/blog/a-professional-writer-and-journalists-text-editor

  32. can't look as if to identify anything to disability the. buy clomid now online Rurhrw xnmnel cialis drugs tadalafil online canadian pharmacy

  33. get lasix online where to buy lasix in Phoenix order usa lasix online http://lasifurex.com/ buy lasix in Hungary purchase lasix from Israel buy lasix on line buy lasix with free samples cheap lasix pills cheap lasix in Sweden top 3 best places to buy lasix in Nashville-Davidson lasix online pharmacy in Buffalo

  34. how to buy lasix in Portugal lasix samples in canada top 9 best places to buy lasix in Netherlands http://lasifurex.com/ how to buy lasix in Baltimore where to buy lasix in Buffalo online cost of lasix medication best price for lasix in Oakland buy lasix in Boston how to buy lasix in Baltimore generic lasix next day delivery where to buy lasix in Indianapolis online

  35. Fantastic beat ! I would like to apprentice while you amend your website, how can i subscribe forr a blig website? Thee account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear idea https://castlewritingpaper269.blogspot.com help me write my research paper help me write my research paper https://writingaparisonpaper980.blogspot.com/2020/09/best-essay-writing-services-from.html

  36. Why viewers still make use of to read news papers when in this technological world all is presented on net? https://comprarcialis5mgonline.com/marca-cialis-professional-20-mg.html buy cialis online canadian pharmacy

Leave a Reply