Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/helm v3 overall upgrade #547

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion approvals/approvals.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func New(opts *Opts) *DefaultManager {
// StartExpiryService - starts approval expiry service which deletes approvals
// that already reached their deadline
func (m *DefaultManager) StartExpiryService(ctx context.Context) error {
ticker := time.NewTicker(60 * time.Minute)
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
err := m.expireEntries()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion chart/keel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: keel
description: Open source, tool for automating Kubernetes deployment updates. Keel is stateless, robust and lightweight.
version: 0.9.4
version: 0.10.0
# Note that we use appVersion to get images tag, so make sure this is correct.
appVersion: 0.16.1
keywords:
Expand Down
23 changes: 0 additions & 23 deletions chart/keel/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,14 @@ spec:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secret/google-application-credentials.json
{{- end }}
{{- if .Values.polling.enabled }}
# Enable polling
- name: POLL
value: "true"
{{- else }}
# Disable polling
- name: POLL
value: "false"
{{- end }}
{{- if .Values.helmProvider.enabled }}
{{- if eq .Values.helmProvider.version "v2" }}
# Enable/disable Helm provider
- name: HELM_PROVIDER
value: "true"
- name: TILLER_NAMESPACE
value: "{{ .Values.helmProvider.tillerNamespace }}"
- name: TILLER_ADDRESS
value: "{{ .Values.helmProvider.tillerAddress }}"
{{- else if eq .Values.helmProvider.version "v3" }}
# Enable/disable Helm provider
- name: HELM3_PROVIDER
value: "true"
{{- if .Values.helmProvider.helmDriver }}
- name: HELM_DRIVER
value: "{{ .Values.helmProvider.helmDriver }}"
{{- end }}
{{- if .Values.helmProvider.helmDriverSqlConnectionString }}
- name: HELM_DRIVER_SQL_CONNECTION_STRING
value: "{{ .Values.helmProvider.helmDriverSqlConnectionString }}"
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.gcr.enabled }}
# Enable GCR with pub/sub support
Expand Down
21 changes: 7 additions & 14 deletions chart/keel/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ image:
# Enable insecure registries
insecureRegistry: false

# Polling is enabled by default,
# you can disable it setting value below to false
polling:
enabled: true

# Helm provider support
helmProvider:
enabled: true
# set to version "v3" for Helm v3
version: "v2"
tillerNamespace: "kube-system"
# optional Tiller address (if portforwarder tunnel doesn't work),
# if you are using default configuration, setting it to
# 'tiller-deploy:44134' is usually fine
tillerAddress: 'tiller-deploy:44134'
# helmDriver: ''
# helmDriverSqlConnectionString: ''
# Additional Helm configuration, more info here:
# https://helm.sh/docs/helm/helm/
#
# helmDriver sets HELM_DRIVER
helmDriver: ""
# helmDriverSqlConnectionString sets HELM_DRIVER_SQL_CONNECTION_STRING
helmDriverSqlConnectionString: ""

# Google Container Registry
# GCP Project ID
Expand Down
60 changes: 7 additions & 53 deletions cmd/keel/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"
"os/signal"
"path/filepath"
Expand All @@ -13,12 +12,10 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
kube "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/helm/pkg/helm/portforwarder"

"github.com/keel-hq/keel/approvals"
"github.com/keel-hq/keel/bot"

// "github.com/keel-hq/keel/cache/memory"
"github.com/keel-hq/keel/pkg/auth"
"github.com/keel-hq/keel/pkg/http"
"github.com/keel-hq/keel/pkg/store"
Expand All @@ -30,7 +27,6 @@ import (
"github.com/keel-hq/keel/internal/k8s"
"github.com/keel-hq/keel/internal/workgroup"
"github.com/keel-hq/keel/provider"
"github.com/keel-hq/keel/provider/helm"
"github.com/keel-hq/keel/provider/helm3"
"github.com/keel-hq/keel/provider/kubernetes"
"github.com/keel-hq/keel/registry"
Expand Down Expand Up @@ -66,16 +62,13 @@ import (

// gcloud pubsub related config
const (
EnvTriggerPubSub = "PUBSUB" // set to 1 or something to enable pub/sub trigger
EnvTriggerPoll = "POLL" // set to 0 to disable poll trigger
EnvProjectID = "PROJECT_ID"
EnvClusterName = "CLUSTER_NAME"
EnvDataDir = "XDG_DATA_HOME"
EnvHelmProvider = "HELM_PROVIDER" // helm provider
EnvHelmTillerAddress = "TILLER_ADDRESS" // helm provider
EnvHelmTillerNamespace = "TILLER_NAMESPACE" // helm provider
EnvHelm3Provider = "HELM3_PROVIDER" // helm3 provider
EnvUIDir = "UI_DIR"
EnvTriggerPubSub = "PUBSUB" // set to 1 or something to enable pub/sub trigger
EnvTriggerPoll = "POLL" // set to 0 to disable poll trigger
EnvProjectID = "PROJECT_ID"
EnvClusterName = "CLUSTER_NAME"
EnvDataDir = "XDG_DATA_HOME"
EnvHelmProvider = "HELM_PROVIDER" // helm provider
EnvUIDir = "UI_DIR"

// EnvDefaultDockerRegistryCfg - default registry configuration that can be passed into
// keel for polling trigger
Expand Down Expand Up @@ -322,45 +315,6 @@ func setupProviders(opts *ProviderOpts) (providers provider.Providers) {
enabledProviders = append(enabledProviders, k8sProvider)

if os.Getenv(EnvHelmProvider) == "1" || os.Getenv(EnvHelmProvider) == "true" {

var tillerAddr string

if os.Getenv(EnvHelmTillerAddress) != "" {
tillerAddr = os.Getenv(EnvHelmTillerAddress)
log.Infof("Tiller address specified: %s", tillerAddr)
} else {
tillerNamespace := "kube-system"
if os.Getenv(EnvHelmTillerNamespace) != "" {
tillerNamespace = os.Getenv(EnvHelmTillerNamespace)
}

tillerTunnel, err := portforwarder.New(tillerNamespace, opts.k8sClient, opts.config)
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Fatal("failed to setup Tiller tunnel")
}

tillerAddr = fmt.Sprintf("127.0.0.1:%d", tillerTunnel.Local)
log.Infof("created local tunnel using local port: '%d'", tillerTunnel.Local)
}

helmImplementer := helm.NewHelmImplementer(tillerAddr)
helmProvider := helm.NewProvider(helmImplementer, opts.sender, opts.approvalsManager)

go func() {
err := helmProvider.Start()
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Fatal("helm provider stopped with an error")
}
}()

enabledProviders = append(enabledProviders, helmProvider)
}

if os.Getenv(EnvHelm3Provider) == "1" || os.Getenv(EnvHelm3Provider) == "true" {
helm3Implementer := helm3.NewHelm3Implementer()
helm3Provider := helm3.NewProvider(helm3Implementer, opts.sender, opts.approvalsManager)

Expand Down
12 changes: 2 additions & 10 deletions extension/credentialshelper/credentialshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ func GetCredentials(image *types.TrackedImage) (*types.Credentials, error) {
if credHelper.IsEnabled() {
foundCredentials, err := credHelper.GetCredentials(image)
if err != nil {
if err == ErrUnsupportedRegistry {
log.WithFields(log.Fields{
"helper": name,
"error": err,
"tracked_image": image,
}).Debug("extension.credentialshelper: helper doesn't support this registry")
} else {
if err != ErrUnsupportedRegistry {
log.WithFields(log.Fields{
"helper": name,
"error": err,
Expand All @@ -101,8 +95,6 @@ func GetCredentials(image *types.TrackedImage) (*types.Credentials, error) {
return foundCredentials, nil
}
}
log.WithFields(log.Fields{
"tracked_image": image,
}).Debug("extension.credentialshelper: credentials helper not found")

return nil, ErrCredentialsNotAvailable
}
71 changes: 33 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,68 @@ module github.com/keel-hq/keel

go 1.14

replace (
k8s.io/api => k8s.io/api v0.16.10
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.16.10
k8s.io/apimachinery => k8s.io/apimachinery v0.16.10
k8s.io/apiserver => k8s.io/apiserver v0.16.10
k8s.io/cli-runtime => k8s.io/cli-runtime v0.16.10
k8s.io/client-go => k8s.io/client-go v0.16.10
k8s.io/cloud-provider => k8s.io/cloud-provider v0.16.10
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.16.10
k8s.io/code-generator => k8s.io/code-generator v0.16.10
k8s.io/component-base => k8s.io/component-base v0.16.10
k8s.io/cri-api => k8s.io/cri-api v0.16.10
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.16.10
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.16.10
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.16.10
k8s.io/kube-proxy => k8s.io/kube-proxy v0.16.10
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.16.10
k8s.io/kubectl => k8s.io/kubectl v0.16.10
k8s.io/kubelet => k8s.io/kubelet v0.16.10
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.16.10
k8s.io/metrics => k8s.io/metrics v0.16.10
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.16.10
)
// replace (
// k8s.io/api => k8s.io/api v0.16.10
// k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.16.10
// k8s.io/apimachinery => k8s.io/apimachinery v0.16.10
// k8s.io/apiserver => k8s.io/apiserver v0.16.10
// k8s.io/cli-runtime => k8s.io/cli-runtime v0.16.10
// k8s.io/client-go => k8s.io/client-go v0.16.10
// k8s.io/cloud-provider => k8s.io/cloud-provider v0.16.10
// k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.16.10
// k8s.io/code-generator => k8s.io/code-generator v0.16.10
// k8s.io/component-base => k8s.io/component-base v0.16.10
// k8s.io/cri-api => k8s.io/cri-api v0.16.10
// k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.16.10
// k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.16.10
// k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.16.10
// k8s.io/kube-proxy => k8s.io/kube-proxy v0.16.10
// k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.16.10
// k8s.io/kubectl => k8s.io/kubectl v0.16.10
// k8s.io/kubelet => k8s.io/kubelet v0.16.10
// k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.16.10
// k8s.io/metrics => k8s.io/metrics v0.16.10
// k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.16.10
// )

replace (
helm.sh/helm/v3 => helm.sh/helm/v3 v3.1.2
helm.sh/helm/v3 => helm.sh/helm/v3 v3.3.1
k8s.io/helm => k8s.io/helm v2.16.7+incompatible
)

replace k8s.io/kubernetes => k8s.io/kubernetes v1.16.10
// replace k8s.io/kubernetes => k8s.io/kubernetes v1.16.10

require (
cloud.google.com/go/pubsub v1.4.0
github.com/Masterminds/semver v1.5.0
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/aws/aws-sdk-go v1.31.10
github.com/daneharrigan/hipchat v0.0.0-20170512185232-835dc879394a
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.4.2
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.4
github.com/jinzhu/gorm v1.9.12
github.com/jmoiron/sqlx v1.2.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mfridman/tparse v0.8.2 // indirect
github.com/nlopes/slack v0.6.0
github.com/opencontainers/go-digest v1.0.0
github.com/prometheus/client_golang v1.6.0
github.com/rubenv/sql-migrate v0.0.0-20200429072036-ae26b214fa43 // indirect
github.com/rusenask/cron v1.1.0
github.com/rusenask/docker-registry-client v0.0.0-20200210164146-049272422097
github.com/ryanuber/go-glob v1.0.0
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.6.1
github.com/tbruyelle/hipchat-go v0.0.0-20170717082847-35aebc99209a
github.com/urfave/negroni v1.0.0
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
google.golang.org/api v0.26.0
google.golang.org/grpc v1.29.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
helm.sh/helm/v3 v3.0.0-00010101000000-000000000000
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/cli-runtime v0.17.2
k8s.io/client-go v0.17.2
k8s.io/helm v0.0.0-00010101000000-000000000000
sigs.k8s.io/yaml v1.1.0
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/cli-runtime v0.18.8
k8s.io/client-go v0.18.8
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/yaml v1.2.0
)
Loading