<p><strong>What I want to do:</strong></p>

<p>For my own educational purposes I'm trying to start a kube API server and register a kubelet as a node into it. I'm doing this exercise into a vagrant box which runs linux and a docker runtime. </p>

<p><strong>What I did so far is:</strong></p>

<ol>
<li>I've run a dockerized etcd using the host network:</li>
</ol>

<pre><code>$docker run --volume=$PWD/etcd-data:/default.etcd --detach --net=host quay.io/coreos/etcd

$docker ps
CONTAINER ID        IMAGE                 COMMAND                 CREATED             STATUS              PORTS               NAMES
3f4a42fce24a        quay.io/coreos/etcd   "/usr/local/bin/etcd"   2 hours ago         Up 2 hours                              awesome_bartik
</code></pre>

<ol start="2">
<li>I've started the API server connecting it to etcd</li>
</ol>

<pre><code>$./kube-apiserver --etcd-servers=http://127.0.0.1:2379 --service-cluster-ip-range=10.0.0.0/16 
</code></pre>

<p>The server v.1.16 is up and running as seen next:</p>

<pre><code>$curl http://localhost:8080/version
{
  "major": "1",
  "minor": "16",
  "gitVersion": "v1.16.0",
  "gitCommit": "2bd9643cee5b3b3a5ecbd3af49d09018f0773c77",
  "gitTreeState": "clean",
  "buildDate": "2019-09-18T14:27:17Z",
  "goVersion": "go1.12.9",
  "compiler": "gc",
  "platform": "linux/amd64"
}
</code></pre>

<p>No nodes are registered yet.</p>

<p><strong>What I can't yet achieve:</strong></p>

<p>Now I want to start the kubelet and register it as a Node. In earlier versions this was maybe possible with the <code>--api-servers</code> flag but this flag is already removed and the configuration is supposed to be in a separate kubelet config file.</p>

<p>My question is how to configure the access to the API server in the kubelet configuration file?  Similar discussion is available <a href="https://github.com/kubernetes/kubernetes/issues/36745" rel="nofollow noreferrer">here</a> but it did not help me too much. The kubelet configuration options are available <a href="https://github.com/kubernetes/kubelet/blob/master/config/v1beta1/types.go" rel="nofollow noreferrer">here</a>.</p>

<p>So far the config file looks like this... Seems that <code>staticPodURL</code> is definitely not the right config :-)</p>

<pre><code>kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
staticPodURL: http://localhost:8080
failSwapOn: false
authentication:
  anonymous:
    enabled: true
  webhook:
    enabled: false
authorization:
  mode: AlwaysAllow
</code></pre>

Lachezar Balev
<p>After a good amount of digging I've managed to make the kubelet register into the kube-api server which opens my way for further building of a small k8s cluster component by component.</p>
<p>The flag that I was looking for in the kubelet config is the following:</p>
<blockquote>
<p>--kubeconfig string</p>
<p>Path to a kubeconfig file, specifying how to connect to the API server.  Providing --kubeconfig enables API server
mode, omitting --kubeconfig enables standalone mode.</p>
</blockquote>
<p>Now I have two config files:</p>
<pre><code>$ cat 02.kubelet-api-server-config.yaml 
apiVersion: v1
kind: Config
clusters:
  - cluster:
      server: http://localhost:8080
    name: kubernetes
contexts:
  - context:
      cluster: kubernetes
    name: system:node:java2dayskube@kubernetes
current-context: system:node:java2dayskube@kubernetes
preferences: {}


$ cat 02.kubelet-base-config.yaml 
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
staticPodURL: http://localhost:8080
failSwapOn: false
authentication:
  anonymous:
    enabled: true
  webhook:
    enabled: false
authorization:
  mode: AlwaysAllow
</code></pre>
<p>As stated above the API server is up and running so I can start the kubelet now:</p>
<pre><code>sudo ./kubelet --config=02.kubelet-base-config.yaml --kubeconfig=02.kubelet-api-server-config.yaml
</code></pre>
<p>Obviously the kubelet registered itself as a node in the API server (details skipped for brevity):</p>
<pre><code>$ curl http://localhost:8080/api/v1/nodes
{
  &quot;kind&quot;: &quot;NodeList&quot;,
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;metadata&quot;: {
    &quot;selfLink&quot;: &quot;/api/v1/nodes&quot;,
    &quot;resourceVersion&quot;: &quot;62&quot;
  },
  &quot;items&quot;: [
    {
      &quot;metadata&quot;: {
        &quot;name&quot;: &quot;vagrant&quot;,
        ...
        &quot;creationTimestamp&quot;: &quot;2019-11-03T09:12:18Z&quot;,
        &quot;labels&quot;: {
          &quot;beta.kubernetes.io/arch&quot;: &quot;amd64&quot;,
          &quot;beta.kubernetes.io/os&quot;: &quot;linux&quot;,
          &quot;kubernetes.io/arch&quot;: &quot;amd64&quot;,
          &quot;kubernetes.io/hostname&quot;: &quot;vagrant&quot;,
          &quot;kubernetes.io/os&quot;: &quot;linux&quot;
        },
        &quot;annotations&quot;: {
          &quot;volumes.kubernetes.io/controller-managed-attach-detach&quot;: &quot;true&quot;
        }
      },
      &quot;spec&quot;: {
        &quot;taints&quot;: [
          {
            &quot;key&quot;: &quot;node.kubernetes.io/not-ready&quot;,
            &quot;effect&quot;: &quot;NoSchedule&quot;
          }
        ]
      }
      ...
} 
</code></pre>
<p>I've managed to create one pod by making a POST request to the api-server. The kubelet was notified and span the corresponding docker containers.</p>
