|
| 1 | +# How to run Preflight with the GKE package |
| 2 | + |
| 3 | +This doc guides you on how to run preflight-agent locally to scan a GKE installation. |
| 4 | + |
| 5 | +As a result, you will get a new cluster in your Preflight account showing reports with the GKE package. |
| 6 | + |
| 7 | +It executes the agent locally because this guide is intented to be an interative demonstration, but the agent could be installed in-cluster as well. Take a look at the [GKE data-gatherer manual](../../datagatherers/gke.md) for further details on how to configure authentication in that scenario. |
| 8 | + |
| 9 | +## Requisites |
| 10 | + |
| 11 | +- A GKE cluster. |
| 12 | +- The `gcloud` CLI tool working locally on your computer. |
| 13 | +- `gcloud` is logged in to an account with permissions to read cluster and GKE state in the project where your cluster is running. |
| 14 | +- You have already run `gcloud container clusters get-credentials [cluster] ...` to configure your kubeconfig. |
| 15 | + |
| 16 | +## Get the preflight cli |
| 17 | + |
| 18 | +Go to [the releases page](https://github.com/jetstack/preflight/releases) and download the binary of the latest stable release for your platform (`v0.1.15` at the moment of writing this). |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +For instance: |
| 23 | + |
| 24 | +``` |
| 25 | +curl -L https://github.com/jetstack/preflight/releases/download/v0.1.15/preflight-linux-amd64 > preflight |
| 26 | +chmod +x ./preflight |
| 27 | +``` |
| 28 | + |
| 29 | +Then run this to make sure you downloaded the right thing: |
| 30 | + |
| 31 | +``` |
| 32 | +./preflight version |
| 33 | +``` |
| 34 | + |
| 35 | +## Access Preflight |
| 36 | + |
| 37 | +> At the moment, Preflight is in private beta. If you are interested, please [email us](mailto:[email protected]?subject=Preflight%20Beta%20Access) and we will grant to access to the beta program. |
| 38 | +
|
| 39 | +If you have an account, you will have an access token. |
| 40 | + |
| 41 | +Enter [preflight.jetstack.io/login](https://preflight.jetstack.io/login) and access with your token. |
| 42 | + |
| 43 | +You will be presented with the list of cluster in your organization. |
| 44 | + |
| 45 | +## Add a new cluster and start agent |
| 46 | + |
| 47 | +Click in "Add Cluster". |
| 48 | + |
| 49 | +Choose a name for your cluster (e.g. `my-gke-cluster`) and click the accept button. |
| 50 | + |
| 51 | +Then you will be presented with instructions to install the agent in a cluster. |
| 52 | + |
| 53 | +Since you are going to run the agent locally instead of installing it in a cluster, you must copy the agent token and craft a config file manually. |
| 54 | + |
| 55 | +You can extract the agent token from the installation command, as shown in the picture. |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +Then you can use this snipped as template for your configuration file and replace the agent token where it corresponds. |
| 60 | + |
| 61 | +Also, change `cluster.project`, `cluster.location`, `cluster.name` accordingly so they point to your GKE cluster (`gcloud container clusters list` if you don't remember those values.). |
| 62 | + |
| 63 | +If you don't specify `credentials`, it will try to use _Gcloud Application Default Credentials_. You can run `gcloud auth application-default login` to make sure your _Application Default Credentials_ are configured. |
| 64 | + |
| 65 | +```yaml |
| 66 | +# config.yaml |
| 67 | + |
| 68 | +schedule: "* * * *" |
| 69 | +token: "<add your agent token here>" |
| 70 | +endpoint: |
| 71 | + protocol: https |
| 72 | + host: "preflight.jetstack.io" |
| 73 | + path: "/api/v1/datareadings" |
| 74 | +data-gatherers: |
| 75 | +- kind: "gke" |
| 76 | + name: "gke" |
| 77 | + config: |
| 78 | + cluster: |
| 79 | + project: my-gcp-project |
| 80 | + location: us-central1-a |
| 81 | + name: my-gke-cluster |
| 82 | + # Path to a file containing the credentials. If empty, it will try to use |
| 83 | + # the SDK defaults |
| 84 | + # credentials: /tmp/credentials.json |
| 85 | +``` |
| 86 | + |
| 87 | +Save the file as `config.yaml`. |
| 88 | + |
| 89 | +Now you can run the Preflight agent: |
| 90 | + |
| 91 | +``` |
| 92 | +./preflight agent -c ./config.yaml |
| 93 | +``` |
| 94 | + |
| 95 | +You should see in the log that it is sending data to the server periodically. |
| 96 | + |
| 97 | +If you go back to the add cluster wizard and click "The agent it ready" |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +## See reports |
| 102 | + |
| 103 | +If you go to the clusters view, you will see the new cluster is there: |
| 104 | + |
| 105 | + |
0 commit comments