# Cheat Sheet

## Enable autocomplete&#x20;

```bash
source <(kops completion bash)
```

## Create cluster

Export your AWS credentials.

```bash
export AWS_ACCESS_KEY_ID=ThyFreeFolk
export AWS_SECRET_ACCESS_KEY=YouShallNotPass
export EC2_REGION=ap-southeast-2
export AWS_DEFAULT_REGION=ap-southeast-2
```

Create a bucket, for example **STATE-BUCKET.**

Then create your cluster.

```bash
kops create cluster \
  --zones=ap-southeast-2a \
  --master-size=t2.small \
  --node-size=t2.medium \
  --node-count=1 \
  --admin-access=0.0.0.0/0 \
  --authorization=AlwaysAllow \
  --cloud=aws \
  --name=YOUR-CLUSTER-NAME \
  --state=s3://STATE-BUCKET
  --yes
```

{% hint style="warning" %}
This setup is not suitable for production environments. **`admin-access`** and **`authorization`** are wide open.
{% endhint %}

Validate cluster

```bash
kops validate cluster
```

## Get cluster credentials

### Get admin password

```bash
kops get secrets kube --type secret -oplaintext
```

### Get token

```bash
kubectl -n kube-system \
  describe secret \
  $(kubectl -n kube-system \
  get secret | awk '/^deployment-controller-token-/{print $1}') | \
  awk '$1=="token:"{print $2}'
```

## Upgrade Kubernetes version

### Before you begin

Double check your Kops and Kubernetes version compatibility.

{% hint style="danger" %}
**DO NOT** upgrade to a Kubernetes version unsuported by your Kops version
{% endhint %}

Check Kops Compatibility Matrix:

{% embed url="<https://github.com/kubernetes/kops#compatibility-matrix>" %}

### Manual upgrade (recommended)

If you don’t know yet, get your cluster’s name:

```bash
kubectl config get-clusters
```

Let’s suppose your cluster name is **my-cluster-name**.

Export an environment variable with your cluster name:

```bash
export NAME=my-cluster-name
```

Edit cluster’s config:

```bash
kops edit cluster $NAME
```

You cluster’s config will be opened in your text editor. Find and replace the config kubernetesVersion, for example:

From:

```
kubernetesVersion: 1.6.0
```

To:

```
kubernetesVersion: 1.9.9
```

Save and exit.

Preview changes:

```bash
kops update cluster $NAME
```

Apply changes:

```bash
kops update cluster $NAME --yes
```

Preview update:

```bash
kops rolling-update cluster $NAME
```

Roll update:

```bash
kops rolling-update cluster $NAME --yes
```

### Automated update

Alternatively you can run Kops auto update:

```bash
kops upgrade cluster $NAME
kops upgrade cluster $NAME --yes
kops update cluster $NAME
kops update cluster $NAME --yes
```

Upgrade uses the latest Kubernetes version considered stable by kops, defined in <https://github.com/kubernetes/kops/blob/master/channels/stable>

### References

<https://github.com/kubernetes/kops/blob/master/docs/upgrade.md>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.devops.buzz/public/kops/cheat-sheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
