--- title: "Get started with Kubernetes" description: "Create your first E2E Kubernetes cluster in MyAccount, connect kubectl to it, and deploy a sample web server on a public IP." content_type: "get-started" product: "kubernetes" platform: "MyAccount" url: "/myaccount/kubernetes/get-started/" --- # Get started with Kubernetes Create a Kubernetes cluster, connect kubectl on your computer to it, and run a sample web server that answers on a public IP. You need kubectl installed on your computer; see [Install Tools](https://kubernetes.io/docs/tasks/tools/) on the Kubernetes site. Kubernetes is offered in Delhi and Chennai. Before you start, choose one of them as the region in MyAccount. If your account is new and you choose Delhi, see [Why can I not create a cluster in Delhi?](/myaccount/kubernetes/faq/#why-can-i-not-create-a-cluster-in-delhi) first. You also need: - A security group in that region with inbound rules for TCP port 6443 and UDP port 8472. See [Create a security group](/myaccount/security-group/how-to/create-a-security-group/) and [Add or edit rules](/myaccount/security-group/how-to/add-or-edit-rules/). - On a prepaid account, infra credits for 24 hours of the master node and the pool's nodes. ## Create the cluster 1. In MyAccount, under **Compute**, click **Kubernetes**, and click **Create New Cluster**. **Create Kubernetes Cluster** opens. 2. **Cluster Name** is filled in for you. Keep it, or enter your own name of up to 50 letters, digits, hyphens, and underscores. 3. Choose a **Kubernetes Version** that your tools support. The cluster keeps its version and its name for its whole life. 4. Under **Plan**, select the **On-Demand** card, which bills the master node by the minute. 5. Under **Worker Node Pool**, click **Add Node Pool**. In the drawer, keep the **Node Pool Name** and the **Static** scaling strategy, which keeps a fixed number of nodes. Set **Node Count** to 2, the fewest a CPU pool holds, which is enough for the sample. 6. Under **Infrastructure Configuration**, choose a CPU family under **Compute Family** and its smallest **Plan**. Choose **On-Demand** under **Billing Plan**, and click **Add Pool**. 7. Under **Network Settings**, choose a VPC. If you have none, click **Create New** to make one without leaving the form. 8. Open **Advanced Settings** and choose the security group that allows TCP port 6443 and UDP port 8472. 9. The **Summary** panel adds up the cost as you choose. Check it, and click **Create Cluster**. Back on the list, with **Kubernetes cluster created successfully. Please wait for 5-10 minutes to configure.**, your cluster reads **Creating**. Wait until it reads **Running**. If it still reads **Creating** after 80 minutes, see [Troubleshooting Kubernetes](/myaccount/kubernetes/troubleshooting/kubernetes/#the-cluster-stays-on-creating). ## Download the kubeconfig 1. In the list, click your cluster's name, and stay on its **Cluster Details** tab. 2. In the **Kubeconfig** row, click the download button. The file is saved as `-kubeconfig.yaml`, where `` is your cluster's name. 3. Move the file to a folder of its own, such as `~/.kube/`, and use that path. On Windows, use `$HOME\.kube\`. 4. Point kubectl at the file for this terminal session: ```bash export KUBECONFIG="$HOME/.kube/-kubeconfig.yaml" ``` On Windows PowerShell, run this instead: ```powershell $env:KUBECONFIG = "$HOME\.kube\-kubeconfig.yaml" ``` 5. List the cluster's nodes: ```bash kubectl get nodes ``` kubectl lists the cluster's nodes, one row each, like this: ```text NAME STATUS ROLES AGE VERSION Ready 5m v ``` A node that reads `Ready` can run pods. If the command times out, see [Troubleshooting Kubernetes](/myaccount/kubernetes/troubleshooting/kubernetes/#kubectl-times-out-on-port-6443). ## Deploy a sample application Create a Deployment that runs two copies of the NGINX web server: ```bash kubectl create deployment hello --image=nginx --replicas=2 kubectl get pods ``` Both pods read `Running` once their image has been pulled: ```text NAME READY STATUS RESTARTS AGE hello- 1/1 Running 0 30s hello- 1/1 Running 0 30s ``` ## Expose it on a public IP A LoadBalancer service gets its external IP from the cluster's **LB IP Pool**, one IP per service, so attach a public service IP to the pool first. 1. On your cluster's page, open the **LB IP Pool** tab. 2. If the tab says **Currently no reserved Service IP is available**, click **Click here** to reserve one. A public service IP counts toward your account's reserved-IP limit, and reserving one needs enough infra credits. 3. When the tab says **Currently no Service IP attached**, click **Click here**. **Attach Public IP** opens. 4. Under **Select IP**, choose the IP, and click **Attach IP**. The IP is listed under **Service IP**. 5. Create a LoadBalancer service for the Deployment, and watch it get its address: ```bash kubectl expose deployment hello --type=LoadBalancer --port=80 kubectl get service hello --watch ``` kubectl prints a new line each time the service changes, `` first, then the IP: ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello LoadBalancer 80:/TCP 2s hello LoadBalancer 80:/TCP 5s ``` When `EXTERNAL-IP` changes from `` to the public service IP you attached, press Ctrl+C and open `http://` in a browser, where `` is that address. The NGINX welcome page opens. Your first application is running on your cluster. A public service IP is billed from when you reserve it until you release it. For current prices, see [E2E's pricing page](https://www.e2enetworks.com/pricing). ## (Optional) Run images from a private registry To run images from E2E's Container Registry, see [Pull images from a Kubernetes pod](/myaccount/container-registry/how-to/pull-images-from-a-kubernetes-pod/). For another private registry, store its credentials in a secret with `kubectl create secret docker-registry`, and list the secret under the pod's image pull secrets. ## Clean up When you have finished trying the sample, remove it so the public service IP is free again: ```bash kubectl delete service hello kubectl delete deployment hello ``` The public service IP stays reserved, and billed, until you release it. To stop the charge, detach it on the **LB IP Pool** tab and delete it; see [Delete a reserved IP](/myaccount/reserved-ip/how-to/delete-a-reserved-ip/). To remove the whole cluster, see [Delete a cluster](/myaccount/kubernetes/how-to/delete-a-cluster/). ## What to do next - [Create a cluster](/myaccount/kubernetes/how-to/create-a-cluster/): every choice on the create form, including committed billing, autoscaling pools, subnets, and encryption. - [Connect to a cluster with kubectl](/myaccount/kubernetes/how-to/connect-with-kubectl/): keep the kubeconfig set for every session, and open the Kubernetes Dashboard. - [Expose a service with a load balancer](/myaccount/kubernetes/how-to/expose-a-service-with-a-load-balancer/): write the service as a manifest, and give it a private LB IP for traffic inside the VPC. - [Use persistent volumes](/myaccount/kubernetes/how-to/use-persistent-volumes/): keep your application's data when its pods restart. - [Troubleshooting Kubernetes](/myaccount/kubernetes/troubleshooting/kubernetes/) and [Kubernetes FAQ](/myaccount/kubernetes/faq/): fixes and short answers when something does not go as expected.