{"id":6275,"date":"2019-07-26T18:31:14","date_gmt":"2019-07-26T18:31:14","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=6275"},"modified":"2021-11-16T11:13:28","modified_gmt":"2021-11-16T11:13:28","slug":"working-with-kubernetes-cluster-using-kubectl-part-3-api-objects","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/working-with-kubernetes-cluster-using-kubectl-part-3-api-objects\/","title":{"rendered":"Kubernetes Commands: kubectl api-resources &#8211; Tutorials and Examples"},"content":{"rendered":"\n<p>POD.yaml<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">apiVersion: v1\nkind: Pod\nmetadata:\n  name: hello-world\nspec:\n  containers:\n  - name: hello-world\n    image: gcr.io\/google-samples\/hello-app:1.0<\/code><\/span><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">ssh aen@c1-master1\ncd ~\/content\/course\/m2\/demos\n\n<span class=\"hljs-comment\">#Get information about our current context, ensure we're logged into the correct cluster.<\/span>\nkubectl config get-contexts\n\n<span class=\"hljs-comment\">#Change our context if needed.<\/span>\nkubectl config <span class=\"hljs-keyword\">use<\/span>-<span class=\"hljs-title\">context<\/span> <span class=\"hljs-title\">kubernetes<\/span>-<span class=\"hljs-title\">admin<\/span>@<span class=\"hljs-title\">kubernetes<\/span>\n\n#<span class=\"hljs-title\">Get<\/span> <span class=\"hljs-title\">information<\/span> <span class=\"hljs-title\">about<\/span> <span class=\"hljs-title\">the<\/span> <span class=\"hljs-title\">API<\/span> <span class=\"hljs-title\">Server<\/span> <span class=\"hljs-title\">for<\/span> <span class=\"hljs-title\">our<\/span> <span class=\"hljs-title\">current<\/span> <span class=\"hljs-title\">context<\/span>, <span class=\"hljs-title\">which<\/span> <span class=\"hljs-title\">should<\/span> <span class=\"hljs-title\">be<\/span> <span class=\"hljs-title\">kubernetes<\/span>-<span class=\"hljs-title\">admin<\/span>@<span class=\"hljs-title\">kubernetes<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">cluster<\/span>-<span class=\"hljs-title\">info<\/span>\n\n#<span class=\"hljs-title\">Get<\/span> <span class=\"hljs-title\">a<\/span> <span class=\"hljs-title\">list<\/span> <span class=\"hljs-title\">of<\/span> <span class=\"hljs-title\">API<\/span> <span class=\"hljs-title\">Resources<\/span> <span class=\"hljs-title\">available<\/span> <span class=\"hljs-title\">in<\/span> <span class=\"hljs-title\">the<\/span> <span class=\"hljs-title\">cluster<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">api<\/span>-<span class=\"hljs-title\">resources<\/span> | <span class=\"hljs-title\">more<\/span>\n\n#<span class=\"hljs-title\">Using<\/span> <span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">explain<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">explain<\/span> <span class=\"hljs-title\">pods<\/span> | <span class=\"hljs-title\">more<\/span>\n\n#<span class=\"hljs-title\">Creating<\/span> <span class=\"hljs-title\">a<\/span> <span class=\"hljs-title\">pod<\/span> <span class=\"hljs-title\">with<\/span> <span class=\"hljs-title\">YAML<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">apply<\/span> -<span class=\"hljs-title\">f<\/span> <span class=\"hljs-title\">pod<\/span>.<span class=\"hljs-title\">yaml<\/span>\n\n#<span class=\"hljs-title\">Let<\/span>'<span class=\"hljs-title\">s<\/span> <span class=\"hljs-title\">look<\/span> <span class=\"hljs-title\">more<\/span> <span class=\"hljs-title\">closely<\/span> <span class=\"hljs-title\">at<\/span> <span class=\"hljs-title\">what<\/span> <span class=\"hljs-title\">we<\/span> <span class=\"hljs-title\">need<\/span> <span class=\"hljs-title\">in<\/span> <span class=\"hljs-title\">pod<\/span>.<span class=\"hljs-title\">spec<\/span> <span class=\"hljs-title\">and<\/span> <span class=\"hljs-title\">pod<\/span>.<span class=\"hljs-title\">spec<\/span>.<span class=\"hljs-title\">containers<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">explain<\/span> <span class=\"hljs-title\">pod<\/span>.<span class=\"hljs-title\">spec<\/span> | <span class=\"hljs-title\">more<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">explain<\/span> <span class=\"hljs-title\">pod<\/span>.<span class=\"hljs-title\">spec<\/span>.<span class=\"hljs-title\">containers<\/span> | <span class=\"hljs-title\">more<\/span>\n\n#<span class=\"hljs-title\">Get<\/span> <span class=\"hljs-title\">a<\/span> <span class=\"hljs-title\">list<\/span> <span class=\"hljs-title\">of<\/span> <span class=\"hljs-title\">our<\/span> <span class=\"hljs-title\">currently<\/span> <span class=\"hljs-title\">running<\/span> <span class=\"hljs-title\">pods<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">get<\/span> <span class=\"hljs-title\">pod<\/span> \n\n#<span class=\"hljs-title\">Remove<\/span> <span class=\"hljs-title\">our<\/span> <span class=\"hljs-title\">pod<\/span>\n<span class=\"hljs-title\">kubectl<\/span> <span class=\"hljs-title\">delete<\/span> <span class=\"hljs-title\">pod<\/span> <span class=\"hljs-title\">hello<\/span>-<span class=\"hljs-title\">world<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_27906\"><iframe loading=\"lazy\"  id=\"_ytid_60960\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_27906\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>POD.yaml<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4859],"tags":[],"class_list":["post-6275","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=6275"}],"version-history":[{"count":7,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6275\/revisions"}],"predecessor-version":[{"id":25482,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6275\/revisions\/25482"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=6275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=6275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=6275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}