Skip to content

Commit

Permalink
Merge pull request #1 from Tatsinnit/helm
Browse files Browse the repository at this point in the history
Helm - Some contributions to the repo
  • Loading branch information
sophsoph321 authored May 19, 2021
2 parents 3ab7dda + 5378cd4 commit 80518c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
4 changes: 4 additions & 0 deletions builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor github.com/Azure/aks-periscope

FROM alpine
RUN apk --no-cache add ca-certificates
RUN apk add --no-cache curl openssl bash
ADD https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 \
&& chmod +x get_helm.sh \
&& ./get_helm.sh
RUN mkdir /app
WORKDIR /app
COPY --from=builder /app/aks-periscope .
Expand Down
4 changes: 2 additions & 2 deletions deployment/aks-periscope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ metadata:
name: aks-periscope-role
rules:
- apiGroups: ["","metrics.k8s.io"]
resources: ["pods", "nodes"]
resources: ["pods", "nodes", "secrets"]
verbs: ["get", "watch", "list"]
- apiGroups: ["aks-periscope.azure.github.com"]
resources: ["diagnostics"]
Expand Down Expand Up @@ -140,7 +140,7 @@ metadata:
name: clustertype-config
namespace: aks-periscope
data:
CLUSTER_TYPE: # <custom flag>
CLUSTER_TYPE: "managedCluster" # <custom flag>
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
Expand Down
37 changes: 5 additions & 32 deletions pkg/collector/helm_collector.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package collector

import (
"path/filepath"

"github.com/Azure/aks-periscope/pkg/interfaces"
"github.com/Azure/aks-periscope/pkg/utils"
"path/filepath"
)

// HelmCollector defines a Helm Collector struct
Expand All @@ -30,34 +31,10 @@ func (collector *HelmCollector) Collect() error {
return err
}

output, err := utils.RunCommandOnContainer("apk", "add", "curl", "openssl", "bash", "--no-cache")
if err != nil {
return err
}

output, err = utils.RunCommandOnContainer("curl", "-fsSl", "-o", "get_helm.sh", "https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3")
if err != nil {
return err
}

output, err = utils.RunCommandOnContainer("chmod", "+x", "get_helm.sh")
if err != nil {
return err
}

output, err = utils.RunCommandOnContainer("./get_helm.sh")
if err != nil {
return err
}

helmListFile := filepath.Join(rootPath, "helm_list")
output, err = utils.RunCommandOnContainer("helm", "list", "--all-namespaces")
output, err := utils.RunCommandOnContainer("helm", "list", "--all-namespaces")
if err != nil {
errorMessage := err.Error()
err = utils.WriteToFile(helmListFile, errorMessage)
if err != nil {
return err
}
return err
}

err = utils.WriteToFile(helmListFile, output)
Expand All @@ -70,11 +47,7 @@ func (collector *HelmCollector) Collect() error {
helmHistoryFile := filepath.Join(rootPath, "helm_history")
output, err = utils.RunCommandOnContainer("helm", "history", "-n", "default", "azure-arc")
if err != nil {
errorMessage := err.Error()
err = utils.WriteToFile(helmHistoryFile, errorMessage)
if err != nil {
return err
}
return err
}

err = utils.WriteToFile(helmHistoryFile, output)
Expand Down

0 comments on commit 80518c0

Please sign in to comment.