<p>I have tried to install Kubernetes on Amazon Linux Machine. I followed a lot of documents and videos in those tutorials they are easily installing kubectl and kops but in my case, I followed the same steps but kubectl is not working for me.</p>

<p>error: The connection to the server localhost:8080 was refused - did you specify the right host or port? I opened all required ports still effecting with the error.</p>

<p><a href="https://i.stack.imgur.com/3aqh7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3aqh7.png" alt="enter image description here"></a></p>

Rakesh Sivagouni
<p>1) kubelet is not a service, it's just a binary executable file so there is no any service unit file for it on your system</p>

<p>2) How did you use kops to deploy cluster on aws? I always use the following steps which work for me:</p>

<p>Install <code>awscli</code></p>

<pre><code>sudo apt-get install python python-pip
sudo python-pip install awscli
</code></pre>

<p>Create aws credentials for your <strong>admin user</strong> (using IAM) and configure your awscli utility to use them</p>

<pre><code>aws configure
</code></pre>

<p>Install <code>kops</code></p>

<pre><code>curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
</code></pre>

<p>as well as <code>kubectl</code></p>

<pre><code>apt-get update &amp;&amp; apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat &lt;&lt;EOF &gt;/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubectl
</code></pre>

<p>Create <code>s3 bucket</code> for Kubernetes's storage with some name</p>

<pre><code>aws s3api create-bucket --bucket k8s --region eu-central-1 --create-bucket-configuration LocationConstraint=eu-central-1
aws s3api put-bucket-versioning --region eu-central-1 --bucket k8s --versioning-configuration Status=Enabled
aws s3 ls
</code></pre>

<p>Create hosted zone (or subdomain) for Kubernetes cluster in Route53 or use existed one in <code>Route53</code>, for example <code>test.com</code>. </p>

<p>Create cluster via kops:</p>

<pre><code>kops create cluster --name=k8s.test.com \
                    --state=s3://k8s \
                    --zones=eu-central-1a \
                    --node-count=2 \
                    --node-size=t2.small \
                    --master-count=1 \
                    --master-size=t2.micro \
                    --master-zones=eu-central-1a \
                    --dns-zone=test.com \
                    --authorization=RBAC \
                    --yes
</code></pre>

<p>wait for a while and check if it's running:</p>

<pre><code>kops validate cluster --name=k8s.test.com --state=s3://k8s
</code></pre>
