Skip to content

Commit fc93276

Browse files
authored
Merge pull request #30 from j-fuentes/aks-support
Add AKS data-gatherer
2 parents e4131e1 + 6d01b3c commit fc93276

File tree

7 files changed

+548
-80
lines changed

7 files changed

+548
-80
lines changed

cmd/check.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/jetstack/preflight/pkg/datagatherer"
14+
"github.com/jetstack/preflight/pkg/datagatherer/aks"
1415
"github.com/jetstack/preflight/pkg/datagatherer/eks"
1516
"github.com/jetstack/preflight/pkg/datagatherer/gke"
1617
"github.com/jetstack/preflight/pkg/datagatherer/k8s"
@@ -167,6 +168,27 @@ func check() {
167168
Location: location,
168169
Name: cluster,
169170
}, credentialsPath)
171+
} else if name == "aks" {
172+
aksConfig, ok := config.(map[string]interface{})
173+
if !ok {
174+
log.Fatal("Cannot parse 'data-gatherers.aks' in config.")
175+
}
176+
msg := "'data-gatherers.aks.%s' should be a non empty string."
177+
var resourceGroup, clusterName, credentialsPath string
178+
if resourceGroup, ok = aksConfig["resource-group"].(string); !ok {
179+
log.Fatalf(msg, "resource-group")
180+
}
181+
if clusterName, ok = aksConfig["cluster"].(string); !ok {
182+
log.Fatalf(msg, "cluster")
183+
}
184+
if credentialsPath, ok = aksConfig["credentials"].(string); !ok {
185+
log.Fatalf(msg, "credentials")
186+
}
187+
var err error
188+
dg, err = aks.NewAKSDataGatherer(ctx, resourceGroup, clusterName, credentialsPath)
189+
if err != nil {
190+
log.Fatalf("Cannot instantiate AKS datagatherer: %v", err)
191+
}
170192
} else if name == "k8s/pods" {
171193
podsConfig, ok := config.(map[string]interface{})
172194
if !ok {

examples/aks.preflight.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cluster-name: my-cluster
2+
3+
data-gatherers:
4+
aks:
5+
cluster: preflight-test
6+
resource-group: preflight
7+
# Generated by running `az account get-access-token > /tmp/credentials.json`
8+
credentials: /tmp/credentials.json
9+
10+
package-sources:
11+
- type: local
12+
dir: preflight-packages/
13+
14+
enabled-packages:
15+
- "examples.jetstack.io/aks_basic"
16+
17+
# This configures how the results will be reported.
18+
outputs:
19+
# writes a human readable doc that can be opened with a browser.
20+
- type: local
21+
path: ./output
22+
format: json
23+
# writes a file with the data gathered.
24+
- type: local
25+
path: ./output
26+
format: intermediate
27+
# writes a the report to the CLI.
28+
- type: cli

go.mod

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module github.com/jetstack/preflight
22

3-
go 1.12
3+
go 1.13
44

55
require (
6-
cloud.google.com/go/storage v1.2.1
6+
cloud.google.com/go/storage v1.4.0
7+
github.com/Azure/aks-engine v0.43.1
78
github.com/aws/aws-sdk-go v1.25.30
89
github.com/gomarkdown/markdown v0.0.0-20191104174740-4d42851d4d5a
910
github.com/gookit/color v1.2.0
@@ -14,19 +15,19 @@ require (
1415
github.com/mattn/go-colorable v0.1.4 // indirect
1516
github.com/open-policy-agent/opa v0.16.0
1617
github.com/pkg/errors v0.8.1
17-
github.com/sergi/go-diff v1.0.0 // indirect
1818
github.com/spf13/cobra v0.0.5
19-
github.com/spf13/pflag v1.0.3
19+
github.com/spf13/pflag v1.0.5
2020
github.com/spf13/viper v1.5.0
2121
github.com/yudai/gojsondiff v1.0.0
22-
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
23-
github.com/yudai/pp v2.0.1+incompatible // indirect
24-
golang.org/x/arch v0.0.0-20191126211547-368ea8f32fff // indirect
25-
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
26-
google.golang.org/api v0.13.0
27-
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
28-
gopkg.in/yaml.v2 v2.2.5
29-
k8s.io/api v0.0.0-20190620084959-7cf5895f2711
30-
k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
31-
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
22+
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
23+
google.golang.org/api v0.15.0
24+
gopkg.in/yaml.v2 v2.2.7
25+
k8s.io/api v0.17.0
26+
k8s.io/apimachinery v0.17.0
27+
k8s.io/client-go v10.0.0+incompatible
3228
)
29+
30+
// This is needed because otherwise k8s.io/client-go is forced
31+
// to v10.0.0+incompatible because of aks-engine, and that
32+
// causes another set of problems with inconsistent dependencies.
33+
replace k8s.io/client-go => k8s.io/client-go v0.17.0

0 commit comments

Comments
 (0)