You have to create two API tokens:
- Github API token with the
user
scope. - OpenWeather API token.
Having the tokens, replace the values inside the secret.yaml
accordingly.
By default, the cronjob gathers weather information for Berlin,De
. If you want to use different city, change
it in the secret.yaml
file.
expiration_time: 30
github:
...
...
owm:
query: "Cologne,De"
Once the secret is placed in the cluster, deploy the resources:
$ kubectl apply -f deployments/
The cronjob executes every ten minutes. Wait for it or...
Just run:
$ kubectl create job test --from cronjob/github-weather
job.batch/test created
$ kubectl logs -f job/test
2020/04/23 12:28:34 got owm response: {Cod:200 ID:3117735 Name:Madrid Weather:[{ID:801 Main:Clouds Description:few clouds Icon:02d}] Main:{Temp:17.4 FeelsLike:16.31}}
2020/04/23 12:28:34 >> variables: map[status:{github/weather 🌤️ 2020-04-23 12:58:34.365587279 +0000 UTC false Madrid, +17° }]
2020/04/23 12:28:34 >> query:
mutation ($status: ChangeUserStatusInput!) {
changeUserStatus(input: $status) {
status {
id
updatedAt
expiresAt
}
}
}
2020/04/23 12:28:34 >> headers: map[Accept:[application/json; charset=utf-8] Authorization:[bearer ] Content-Type:[application/json; charset=utf-8]]
2020/04/23 12:28:34 << {"data":{"changeUserStatus":{"status":{"id":"1246618","updatedAt":"2020-04-23T12:28:34Z","expiresAt":"2020-04-23T12:58:34Z"}}}}
2020/04/23 12:28:34 set gh status: {ID:1246618 UpdatedAt:2020-04-23 12:28:34 +0000 UTC ExpiresAt:2020-04-23 12:58:34 +0000 UTC}