Answers: <p>I loaded the <code>kubeconfig</code> before and the error disappeared.</p>
  <pre class="lang-bash prettyprint-override"><code>$ export KUBECONFIG=~/workspace/myrepo/_kube/dev/kubeconfig
  $ AWS_ACCESS_KEY_ID=&lt;my_legit_key&gt; AWS_SECRET_ACCESS_KEY=&lt;my_legit_secret_key&gt; kops validate cluster --wait 10m --state=&quot;s3://&lt;my_bucket_name&gt;&quot; --name=&lt;my_cluster_name&gt;
  ## And it worked
  </code></pre>
  <p>If the kubeconfig does not exist yet, then we can export it as well.</p>
  <pre class="lang-bash prettyprint-override"><code>$ kops export kubecfg --admin=87600h0m0s --kubeconfig ~/workspace/myrepo/_kube/dev/kubeconfig --state=s3://my-kops-dev-v4 --name=k8.mydomain.com
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-07T06:25:28.383Z
Answers: 2021-06-07T06:25:28.383Z
Answers: codeaprendiz
Answers: <p>Try running the <a href="https://kops.sigs.k8s.io/cli/kops_get/" rel="nofollow noreferrer"><code>kops get</code></a> command to see if kOps can read the configuration stored in the s3 bucket correctly. If you get an error then you probably have missed a required configuration in your environment. I had a similar issue but I was using <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html" rel="nofollow noreferrer">Named profiles</a> for AWS. I had to set an extra variable <code>export AWS_SDK_LOAD_CONFIG=1</code> for kOps to pick up the settings (I think it was AWS_REGION) correctly. If it's just <code>kops validate</code> that is failing then make sure you are using the correct context.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-07T06:21:46.887Z
Answers: Actually its able to read S3 configuration. What its not able to do is load the kubeconfig. What really helped me is loading the kubeconfig earlier.
Answers: codeaprendiz
Answers: CC BY-SA 4.0
Answers: 2021-06-06T19:01:08.013Z
Answers: 2021-06-06T19:01:08.013Z
Answers: Faheem
Body: <p>I am trying to run validate cluster command as per the documentation <a href="https://kops.sigs.k8s.io/cli/kops_validate/" rel="nofollow noreferrer">kops validate</a></p>
  <p>Strangely it fails with following error</p>
  <pre class="lang-bash prettyprint-override"><code>$ AWS_ACCESS_KEY_ID=&lt;my_legit_key&gt; AWS_SECRET_ACCESS_KEY=&lt;my_legit_secret_key&gt; kops validate cluster --wait 10m --state=&quot;s3://&lt;my_bucket_name&gt;&quot; --name=&lt;my_cluster_name&gt;
  Validating cluster &lt;my_cluster_name&gt;
  
  
  Validation failed: cannot load kubecfg settings for &quot;&lt;my_cluster_name&gt;&quot;: context &quot;&lt;my_cluster_name&gt;&quot; does not exist
  
  </code></pre>
  
Tags: <kubernetes><amazon-web-services><kops>
Title: kops validate cluster fails with even after providing appropriate state and clustername
UserDisplayName: codeaprendiz
ThreadText: # kops validate cluster fails with even after providing appropriate state and clustername
  
  (Asked by: username_0 on 2021-06-06)
  
  I am trying to run validate cluster command as per the documentation [kops validate](https://kops.sigs.k8s.io/cli/kops_validate/)
  
  Strangely it fails with following error
  
  ```bash
  $ AWS_ACCESS_KEY_ID=<my_legit_key> AWS_SECRET_ACCESS_KEY=<my_legit_secret_key> kops validate cluster --wait 10m --state="s3://<my_bucket_name>" --name=<my_cluster_name>
  Validating cluster <my_cluster_name>
  
  Validation failed: cannot load kubecfg settings for "<my_cluster_name>": context "<my_cluster_name>" does not exist
  
  ```
  
  **Tags:** kubernetes, amazon-web-services, kops
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-06-07. Score: 1
  
  I loaded the `kubeconfig` before and the error disappeared.
  
  ```bash
  $ export KUBECONFIG=~/workspace/myrepo/_kube/dev/kubeconfig
  $ AWS_ACCESS_KEY_ID=<my_legit_key> AWS_SECRET_ACCESS_KEY=<my_legit_secret_key> kops validate cluster --wait 10m --state="s3://<my_bucket_name>" --name=<my_cluster_name>
  ## And it worked
  
  ```
  
  If the kubeconfig does not exist yet, then we can export it as well.
  
  ```bash
  $ kops export kubecfg --admin=87600h0m0s --kubeconfig ~/workspace/myrepo/_kube/dev/kubeconfig --state=s3://my-kops-dev-v4 --name=k8.mydomain.com
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2021-06-06. Score: 0
  
  Try running the [`kops get`](https://kops.sigs.k8s.io/cli/kops_get/) command to see if kOps can read the configuration stored in the s3 bucket correctly. If you get an error then you probably have missed a required configuration in your environment. I had a similar issue but I was using [Named profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) for AWS. I had to set an extra variable `export AWS_SDK_LOAD_CONFIG=1` for kOps to pick up the settings (I think it was AWS\_REGION) correctly. If it's just `kops validate` that is failing then make sure you are using the correct context.
  
  > **Comments:**
  > **username_0**: Actually its able to read S3 configuration. What its not able to do is load the kubeconfig. What really helped me is loading the kubeconfig earlier.  
  
  ---
  
  