# Api Server In this section we will configure kubernetes API server. > The Kubernetes API server validates and configures data for the api objects which include pods, services, replicationcontrollers, and others. The API Server services REST operations and provides the frontend to the cluster's shared state through which all other components interact. As you can see from the description adpi server is central (not main) component of kubernetes cluster. ![image](./img/05_cluster_architecture_apiserver.png "Kubelet") ## certificates Before we begin with configuration of API server, we need to create certificates for kubernetes that will be used to sign service account tokens. ```bash { cat > service-account-csr.json < /var/lib/kubernetes/encryption-config.yaml < ... ``` ## communication with api server Now, when our server is up and running, we want to communicate with it. To do that we will use cubectl tool. So lets download and install it ```bash wget -q --show-progress --https-only --timestamping \ https://storage.googleapis.com/kubernetes-release/release/v1.21.0/bin/linux/amd64/kubectl \ && chmod +x kubectl \ && sudo mv kubectl /usr/local/bin/ ``` As our server is configured to use RBAC authorization, we need to authirize to our server in somehow. To do that, we will generate certificate file which will be signed by ca cert, and have "admin" CN property. ```bash { cat > admin-csr.json < pod.yaml apiVersion: v1 kind: Pod metadata: name: hello-world spec: serviceAccountName: hello-world containers: - name: hello-world-container image: busybox command: ['sh', '-c', 'while true; do echo "Hello, World!"; sleep 1; done'] nodeName: ${HOST_NAME} EOF cat < sa.yaml apiVersion: v1 kind: ServiceAccount metadata: name: hello-world automountServiceAccountToken: false EOF kubectl apply -f sa.yaml kubectl apply -f pod.yaml } ``` Note: as you can see, in addition to the pod, we create service account associated with our pod. This step is needed as we have now default service account created in default namespace (service account controller is responsible to create it, but we didn't configure controller manager yet). To check pod status run ```bash kubectl get pod ``` Output: ``` NAME READY STATUS RESTARTS AGE hello-world 0/1 Pending 0 29s ``` As expected we received pod in pending state, because we have now kubelet configured to run pods created in API server. To ensure we can check it ```bash kubectl get nodes ``` Output: ``` NAME STATUS ROLES AGE VERSION ``` Next: [Apiserver - Kubelet integration](./06-apiserver-kubelet.md)