Skip to content

Commit

Permalink
Merge pull request #75 from intelops/vaultconf
Browse files Browse the repository at this point in the history
Configured  Vault changes
  • Loading branch information
vramk23 authored Feb 7, 2024
2 parents da32e97 + e13d980 commit e8102aa
Show file tree
Hide file tree
Showing 22 changed files with 1,480 additions and 528 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.4 AS builder
FROM golang:1.21 AS builder
WORKDIR /workspace

COPY . ./
Expand Down
2 changes: 1 addition & 1 deletion charts/vault-cred/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.5
version: 0.1.8

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 2 additions & 0 deletions charts/vault-cred/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


23 changes: 23 additions & 0 deletions charts/vault-cred/templates/ingress_route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.ingressroute.enabled -}}
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ include "vaultcred.fullname" . }}-agent
spec:
entryPoints:
- web
- websecure
routes:
- kind: Rule
match: Host(`{{ .Values.ingressroute.host }}`)
services:
- name: vault-cred
port: {{ .Values.service.port }}
scheme: h2c
{{- if .Values.ingressroute.mtls.enabled }}
tls:
options:
name: {{ include "vaultcred.fullname" . }}-mtls-auth
secretName: {{ .Values.cert.secretName }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/vault-cred/templates/rbac/rbac_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ rules:
- events
verbs:
- create
- apiGroups: ["external-secrets.io"]
resources: ["externalsecrets"]
verbs: ["create", "get", "update", "delete"]
3 changes: 3 additions & 0 deletions charts/vault-cred/templates/rbac/rbac_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ roleRef:
kind: ClusterRole
name: {{ include "vaultcred.fullname" . }}-role
apiGroup: rbac.authorization.k8s.io



2 changes: 1 addition & 1 deletion charts/vault-cred/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ metadata:
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 16 additions & 5 deletions charts/vault-cred/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ serviceAccount:

podAnnotations: {}

podSecurityContext: {}
podSecurityContext:
{}
# fsGroup: 2000

securityContext: {}
securityContext:
{}
# capabilities:
# drop:
# - ALL
Expand All @@ -39,7 +41,14 @@ securityContext: {}
service:
type: ClusterIP
port: 8080

ingressroute:
enabled: true
mtls:
enabled: false
host: "vaultcred"

cert:
secretName: "kad-agent-cert"
env:
logLevel: info

Expand Down Expand Up @@ -136,7 +145,8 @@ vaultRoles:
ingress:
enabled: false
className: ""
annotations: {}
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
Expand All @@ -149,7 +159,8 @@ ingress:
# hosts:
# - chart-example.local

resources: {}
resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down
6 changes: 5 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ type Configuration struct {
VaultSealWatchInterval string `envconfig:"VAULT_SEAL_WATCH_INTERVAL"`
VaultPolicyWatchInterval string `envconfig:"VAULT_POLICY_WATCH_INTERVAL"`
VaultCredSyncInterval string `envconfig:"VAULT_CRED_SYNC_INTERVAL"`

}

type VaultEnv struct {
VaultCredAddress string `envconfig:"VAULT_CRED_ADDR" default:"vault-cred:8080"`
HAEnabled bool `envconfig:"HA_ENABLED" default:"true"`
Address string `envconfig:"VAULT_ADDR" required:"true"`
NodeAddresses []string `envconfig:"VAULT_NODE_ADDRESSES" required:"true"`
CACert string `envconfig:"VAULT_CACERT" required:"false"`
ReadTimeout time.Duration `envconfig:"VAULT_READ_TIMEOUT" default:"60s"`
MaxRetries int `envconfig:"VAULT_MAX_RETRIES" default:"5"`
VaultTokenForRequests bool `envconfig:"VAULT_TOKEN_FOR_REQUESTS" default:"false"`
VaultTokenForRequests bool `envconfig:"VAULT_TOKEN_FOR_REQUESTS" default:"true"`
VaultSecretName string `envconfig:"VAULT_SECRET_NAME" default:"vault-server"`
VaultSecretNameSpace string `envconfig:"POD_NAMESPACE" required:"true"`
VaultSecretTokenKeyName string `envconfig:"VAULT_SECRET_TOKEN_KEY_NAME" default:"root-token"`
Expand All @@ -41,3 +43,5 @@ func GetVaultEnv() (VaultEnv, error) {
err := envconfig.Process("", &cfg)
return cfg, err
}


35 changes: 21 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
module github.com/intelops/vault-cred

go 1.19
go 1.21

toolchain go1.21.1

require (
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/hashicorp/vault/api v1.9.2
github.com/hashicorp/vault/api/auth/kubernetes v0.4.1
github.com/intelops/go-common v1.0.15
github.com/intelops/go-common v1.0.20
github.com/kelseyhightower/envconfig v1.4.0
github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.1
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
google.golang.org/grpc v1.57.0
google.golang.org/protobuf v1.32.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
Expand All @@ -28,24 +33,27 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/showa-93/go-mask v0.6.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/term v0.7.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

require (
Expand All @@ -64,12 +72,11 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.1.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.27.2
)
Loading

0 comments on commit e8102aa

Please sign in to comment.