{"id":16579,"date":"2024-11-02T09:33:27","date_gmt":"2024-11-02T09:33:27","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16579"},"modified":"2024-11-02T09:34:13","modified_gmt":"2024-11-02T09:34:13","password":"","slug":"installing-and-configuring-kubernetes-on-a-linux-server","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/","title":{"rendered":"Installing and Configuring Kubernetes on a Linux Server"},"content":{"rendered":"\n<p>Here\u2019s a guide to installing and configuring Kubernetes on a Linux server. This guide covers the essential steps for setting up a single-node Kubernetes cluster, commonly used for testing, development, or as a foundation for scaling to a multi-node setup.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Kubernetes?<\/h3>\n\n\n\n<p>It is an open-source platform designed to automate the deployment, scaling, and management of containerized applications. It enables the creation and orchestration of multiple containers across clusters of hosts, providing high availability, scalability, and efficient resource usage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Linux Server<\/strong> (Ubuntu 20.04+, Debian, CentOS 7+ recommended)<\/li>\n\n\n\n<li><strong>Minimum 2 CPUs<\/strong>, <strong>2 GB RAM<\/strong> for a single-node setup<\/li>\n\n\n\n<li><strong>User with sudo privileges<\/strong><\/li>\n\n\n\n<li><strong>Firewall settings<\/strong> adjusted to allow communication between nodes if you\u2019re setting up a multi-node cluster<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Pre-setup Steps<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Disable Swap<\/strong>: Kubernetes requires swap to be disabled.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapoff -a\n\n# Comment out the swap line in \/etc\/fstab to disable swap on boot\nsudo sed -i '\/ swap \/ s\/^\\(.*\\)$\/#\\1\/g' \/etc\/fstab\n<\/code><\/pre>\n\n\n\n<p>   2. <strong>Install Docker or containerd<\/strong>: Kubernetes needs a container runtime, and Docker is a popular choice.<\/p>\n\n\n\n<p><strong>To install Docker:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y docker.io\nsudo systemctl enable --now docker<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install kubeadm, kubelet, and kubectl<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add the Kubernetes apt repository<\/strong> (for Debian\/Ubuntu-based distributions):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y apt-transport-https ca-certificates curl\n\nsudo curl -fsSL https:\/\/packages.cloud.google.com\/apt\/doc\/apt-key.gpg | sudo apt-key add -\necho \"deb https:\/\/apt.kubernetes.io\/ kubernetes-xenial main\" | sudo tee \/etc\/apt\/sources.list.d\/kubernetes.list\n\nsudo apt update<\/code><\/pre>\n\n\n\n<p><strong>2. Install Kubernetes tools:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y kubelet kubeadm kubectl\n\nsudo apt-mark hold kubelet kubeadm kubectl<\/code><\/pre>\n\n\n\n<p><strong>For RHEL-based systems (Like Almalinux\/CentOS), use:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes<\/code><\/pre>\n\n\n\n<p><strong>3. Enable and start kubelet<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable kubelet<br>sudo systemctl start kubelet<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Initialize the Kubernetes Control Plane<\/h2>\n\n\n\n<p>For single-node clusters, the control plane and worker nodes will be on the same server.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialize the cluster<\/strong> with <code>kubeadm<\/code>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo kubeadm init --pod-network-cidr=10.244.0.0\/16<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>--pod-network-cidr=10.244.0.0\/16<\/code> flag specifies the network range for the pod network, which is compatible with several network plugins like Flannel.<\/li>\n<\/ul>\n\n\n\n<p> 2. <strong>Configure kubectl for your user<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p $HOME\/.kube\nsudo cp -i \/etc\/kubernetes\/admin.conf $HOME\/.kube\/config\nsudo chown $(id -u):$(id -g) $HOME\/.kube\/config<\/code><\/pre>\n\n\n\n<p>3. <strong>Save the join command<\/strong>: After initialization, <code>kubeadm<\/code> will provide a command to add worker nodes to your cluster. Save this command as it\u2019s needed for adding additional nodes later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install a Pod Network (Flannel)<\/h2>\n\n\n\n<p>A <strong>pod network<\/strong> enables communication between pods across nodes in a cluster.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Flannel<\/strong> as the network plugin:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl apply -f https:\/\/raw.githubusercontent.com\/coreos\/flannel\/master\/Documentation\/kube-flannel.yml<\/code><\/pre>\n\n\n\n<p>  2. Verify that all nodes are ready by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get nodes<\/code><\/pre>\n\n\n\n<p>You should see the status as <code>Ready<\/code> for your node.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Allow Scheduling on the Control Plane Node (Single-Node Setup Only)<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you\u2019re setting up a single-node cluster, you need to allow the control plane to run pods:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl taint nodes --all node-role.kubernetes.io\/control-plane-<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This removes the taint that prevents the master node from scheduling pods.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Basic kubectl Commands<\/h2>\n\n\n\n<p>Now that your Kubernetes cluster is up and running, you can start interacting with it using <code>kubectl<\/code>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Check Cluster Status<\/strong>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get nodes<br>kubectl get pods -A<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li> <strong>Create a Test Deployment<\/strong>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl create deployment nginx --image=nginx<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Expose Deployment as a Service<\/strong>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl expose deployment nginx --port=80 --type=NodePort<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Get the Service Port<\/strong>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get svc nginx<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Set Up Kubernetes Dashboard (Optional)<\/h2>\n\n\n\n<p>The <strong>Kubernetes Dashboard<\/strong> is a web-based UI that allows you to manage your cluster graphically.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Apply the Dashboard YAML<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v2.2.0\/aio\/deploy\/recommended.yaml<\/code><\/pre>\n\n\n\n<p> 2. <strong>Create a Service Account and Cluster Role Binding<\/strong> for accessing the dashboard:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl create serviceaccount dashboard-admin-sa\n\n\nkubectl create clusterrolebinding dashboard-admin-sa --clusterrole=cluster-admin --serviceaccount=default:dashboard-admin-sa<\/code><\/pre>\n\n\n\n<p>3. <strong>Get the Authentication Token<\/strong> for the dashboard:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get secret $(kubectl get serviceaccount dashboard-admin-sa -o jsonpath=\"{.secrets&#91;0].name}\") -o go-template=\"{{.data.token | base64decode}}\"<\/code><\/pre>\n\n\n\n<p>4. <strong>Access the Dashboard<\/strong>:<\/p>\n\n\n\n<p>Use <code>kubectl proxy<\/code> to access the dashboard locally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl proxy<\/code><\/pre>\n\n\n\n<p>The dashboard will be accessible at:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;localhost:8001\/api\/v1\/namespaces\/kubernetes-dashboard\/services\/https:kubernetes-dashboard:\/proxy\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Scaling and Managing Your Cluster (Optional)<\/h2>\n\n\n\n<p>To scale your Kubernetes setup beyond a single node:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Get the Join Command<\/strong> from the control plane (output from <code>kubeadm init<\/code>).<\/li>\n\n\n\n<li><strong>Run the join command<\/strong> on additional worker nodes to add them to the cluster.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>You\u2019ve now set up a Kubernetes cluster on a Linux server. This guide covered the installation of Kubernetes components, setting up a pod network, and verifying cluster functionality with test deployments. With Kubernetes in place, you can now deploy, manage, and scale containerized applications effectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here\u2019s a guide to installing and configuring Kubernetes on a Linux server. This guide covers the essential steps for setting up a single-node Kubernetes cluster, commonly used for testing, development, or as a foundation for scaling to a multi-node setup. What is Kubernetes? It is an open-source platform designed to automate the deployment, scaling, and [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16579","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-06","word_count":768,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Installing and Configuring Kubernetes on a Linux Server -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Installing and Configuring Kubernetes on a Linux Server -\" \/>\n<meta property=\"og:description\" content=\"Here\u2019s a guide to installing and configuring Kubernetes on a Linux server. This guide covers the essential steps for setting up a single-node Kubernetes cluster, commonly used for testing, development, or as a foundation for scaling to a multi-node setup. What is Kubernetes? It is an open-source platform designed to automate the deployment, scaling, and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-02T09:34:13+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-configuring-kubernetes-on-a-linux-server\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-configuring-kubernetes-on-a-linux-server\\\/\",\"name\":\"Installing and Configuring Kubernetes on a Linux Server -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-11-02T09:33:27+00:00\",\"dateModified\":\"2024-11-02T09:34:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-configuring-kubernetes-on-a-linux-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-configuring-kubernetes-on-a-linux-server\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-configuring-kubernetes-on-a-linux-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Installing and Configuring Kubernetes on a Linux Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Installing and Configuring Kubernetes on a Linux Server -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/","og_locale":"en_US","og_type":"article","og_title":"Installing and Configuring Kubernetes on a Linux Server -","og_description":"Here\u2019s a guide to installing and configuring Kubernetes on a Linux server. This guide covers the essential steps for setting up a single-node Kubernetes cluster, commonly used for testing, development, or as a foundation for scaling to a multi-node setup. What is Kubernetes? It is an open-source platform designed to automate the deployment, scaling, and [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/","article_modified_time":"2024-11-02T09:34:13+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/","name":"Installing and Configuring Kubernetes on a Linux Server -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-11-02T09:33:27+00:00","dateModified":"2024-11-02T09:34:13+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-configuring-kubernetes-on-a-linux-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"Installing and Configuring Kubernetes on a Linux Server"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16579"}],"version-history":[{"count":1,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16579\/revisions"}],"predecessor-version":[{"id":16580,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16579\/revisions\/16580"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16579"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16579"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}