-
Notifications
You must be signed in to change notification settings - Fork 0
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
Secret management with Vault #58
Open
tomaspalma
wants to merge
7
commits into
main
Choose a base branch
from
feature/vault
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a60063
feat: secret management with vault
tomaspalma c676fe4
feat: set data storage for raft and intial raft setup
tomaspalma 76fbc43
feat: started making trust manager work
tomaspalma 784cd22
fix: wrong vault values yaml format was not configuring right
tomaspalma 4094ee2
feat: tls between vault and vault-operator working
tomaspalma 64c932d
feat: retry join for vault ha raft nodes
tomaspalma efa507d
chore: remove affinity restrictions from vault pod
tomaspalma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: trust-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This a certificate authority | ||
apiVersion: cert-manager.io/v1 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: trust-manager-selfsigned-issuer | ||
spec: | ||
selfSigned: {} | ||
--- | ||
|
||
# This is the certificate for the certificate authority | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: trust-manager-example-ca | ||
spec: | ||
isCA: true | ||
commonName: trust-manager-ca | ||
secretName: trust-manager-ca-secret | ||
privateKey: | ||
algorithm: ECDSA | ||
size: 256 | ||
issuerRef: | ||
name: trust-manager-selfsigned-issuer | ||
kind: ClusterIssuer | ||
group: cert-manager.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
kubectl apply -f "$(dirname "$0")" | ||
|
||
helm repo add jetstack https://charts.jetstack.io --force-update | ||
|
||
helm upgrade --install trust-manager jetstack/trust-manager \ | ||
--namespace trust-manager \ | ||
--wait | ||
# --set app.webhook.tls.approverPolicy.enabled=true \ | ||
# --set app.webhook.tls.approverPolicy.certManagerNamespace=cert-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
kind: Namespace | ||
apiVersion: v1 | ||
metadata: | ||
name: vault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: website-cert | ||
namespace: vault | ||
spec: | ||
secretName: website-cert | ||
issuerRef: | ||
name: letsencrypt-production | ||
kind: ClusterIssuer | ||
commonName: vault.niaefeup.pt | ||
dnsNames: | ||
- vault.niaefeup.pt | ||
--- | ||
|
||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: vault-cluster-ca | ||
namespace: vault | ||
spec: | ||
isCA: false | ||
commonName: "*" | ||
ipAddresses: | ||
- 127.0.0.1 | ||
dnsNames: | ||
- vault.vault.svc.cluster.local | ||
- vault-0.vault-internal | ||
- vault-1.vault-internal | ||
- vault-2.vault-internal | ||
secretName: vault-cluster-ca-secret | ||
privateKey: | ||
algorithm: ECDSA | ||
size: 256 | ||
issuerRef: | ||
name: trust-manager-selfsigned-issuer | ||
kind: ClusterIssuer | ||
group: cert-manager.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: traefik.io/v1alpha1 | ||
kind: IngressRoute | ||
metadata: | ||
name: vault-https | ||
namespace: vault | ||
spec: | ||
entryPoints: | ||
- websecure | ||
routes: | ||
- match: Host(`vault.niaefeup.pt`) | ||
kind: Rule | ||
services: | ||
- name: vault-ui | ||
port: 80 | ||
tls: | ||
secretName: website-cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: trust.cert-manager.io/v1alpha1 | ||
kind: Bundle | ||
metadata: | ||
name: vault-cluster-bundle # The bundle name will also be used for the target | ||
spec: | ||
sources: | ||
- useDefaultCAs: true | ||
- secret: | ||
name: "vault-cluster-ca-secret" | ||
key: "tls.crt" | ||
target: | ||
configMap: | ||
key: "trust-bundle.pem" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
helm repo add hashicorp https://helm.releases.hashicorp.com | ||
helm repo update | ||
|
||
kubectl apply -f "$(dirname "$0")"/00-namespaces.yaml | ||
kubectl apply -f "$(dirname "$0")"/01-certificates.yaml | ||
kubectl apply -f "$(dirname "$0")"/02-ingress-routes.yaml | ||
kubectl apply -f "$(dirname "$0")"/vault-sa.yaml | ||
|
||
helm upgrade --install vault hashicorp/vault --namespace vault --values $(dirname $0)/vault-dev-values.yaml | ||
helm upgrade --install vault-secrets-operator hashicorp/vault-secrets-operator --namespace vault --values $(dirname $0)/vault-operator-dev-values.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
helm repo add hashicorp https://helm.releases.hashicorp.com | ||
helm repo update | ||
|
||
kubectl apply -f "$(dirname "$0")"/00-namespaces.yaml | ||
kubectl apply -f "$(dirname "$0")"/01-certificates.yaml | ||
kubectl apply -f "$(dirname "$0")"/02-ingress-routes.yaml | ||
kubectl apply -f "$(dirname "$0")"/03-bundle.yaml | ||
kubectl apply -f "$(dirname "$0")"/vault-sa.yaml | ||
|
||
helm upgrade --install vault hashicorp/vault --namespace vault --values $(dirname $0)/vault-prod-values.yaml | ||
helm upgrade --install vault-secrets-operator hashicorp/vault-secrets-operator --namespace vault --values $(dirname $0)/vault-operator-prod-values.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#https://developer.hashicorp.com/vault/docs/platform/k8s/helm/configuration | ||
server: | ||
dev: | ||
enabled: true | ||
devRootToken: "root" | ||
logLevel: debug | ||
# A service is not needed since we are not going to be using the vault agent injector | ||
ui: | ||
enabled: true | ||
serviceType: "LoadBalancer" | ||
targetPort: 8200 | ||
externalPort: 8200 | ||
|
||
injector: | ||
enabled: "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This is the connection used if no other VaultConnection resources are loaded into the cluster | ||
# For more configuration options, go to https://developer.hashicorp.com/vault/docs/platform/k8s/vso/helm | ||
defaultVaultConnection: | ||
enabled: true | ||
address: "https://vault.vault.svc.cluster.local:8200" | ||
skipTLSVerify: false | ||
controller: | ||
manager: | ||
clientCache: | ||
persistenceModel: direct-encrypted # Encrypted using the Vault Transit engine | ||
storageEncryption: | ||
enabled: true | ||
mount: vault-operator-auth | ||
keyName: vso-client-cache | ||
namespace: vault-operator | ||
transitMount: vault-operator-transit | ||
kubernetes: | ||
role: vault-operator-role | ||
serviceAccount: vault-operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# https://github.com/hashicorp/vault-secrets-operator/blob/main/chart/values.yaml | ||
defaultVaultConnection: | ||
enabled: true | ||
address: "https://vault.vault.svc.cluster.local:8200" | ||
skipTLSVerify: false | ||
caCertSecret: "vault-cluster-ca-secret" | ||
controller: | ||
manager: | ||
clientCache: | ||
persistenceModel: direct-encrypted | ||
storageEncryption: | ||
enabled: true | ||
mount: demo-auth-mount | ||
keyName: vso-client-cache | ||
namespace: vault | ||
transitMount: demo-transit | ||
kubernetes: | ||
role: auth-role-operator | ||
serviceAccount: vault-operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
# SA bound to the VSO namespace for transit engine auth | ||
namespace: vault-secrets-operator-system | ||
name: demo-operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#https://developer.hashicorp.com/vault/docs/platform/k8s/helm/configuration | ||
global: | ||
enabled: true | ||
tlsDisable: false | ||
namespace: vault | ||
|
||
server: | ||
dev: | ||
enabled: false | ||
affinity: null | ||
logLevel: debug | ||
extraEnvironmentVars: | ||
VAULT_CACERT: /opt/vault/tls/ca.crt | ||
VAULT_TLSCERT: /opt/vault/tls/tls.crt | ||
VAULT_TLSKEY: /opt/vault/tls/tls.key | ||
volumes: | ||
- name: tls | ||
secret: | ||
secretName: vault-cluster-ca-secret | ||
volumeMounts: | ||
- name: tls | ||
mountPath: "/opt/vault/tls" | ||
readOnly: true | ||
dataStorage: | ||
enabled: true | ||
size: 2Gi | ||
storageClass: longhorn-locality-retain | ||
mountPath: "/opt/vault/raft" | ||
accessMode: ReadWriteOnce | ||
ha: | ||
enabled: true | ||
raft: | ||
enabled: true | ||
replicas: 3 | ||
setNodeId: true | ||
config: | | ||
ui = true | ||
disable_mlock = true # avoids out of memory errors by blocking swapping of its virtual pages | ||
|
||
listener "tcp" { | ||
address = "0.0.0.0:8200" | ||
cluster_address = "0.0.0.0:8201" | ||
tls_disable = "false" | ||
tls_cert_file = "/opt/vault/tls/tls.crt" | ||
tls_key_file = "/opt/vault/tls/tls.key" | ||
tls_client_ca_file = "/opt/vault/tls/ca.crt" # certificate of the CA root | ||
} | ||
|
||
storage "raft" { | ||
path = "/opt/vault/raft" | ||
|
||
retry_join { | ||
leader_api_addr = "https://vault-0.vault-internal:8200" | ||
leader_ca_cert_file = "/opt/vault/tls/ca.crt" | ||
leader_client_cert_file = "/opt/vault/tls/tls.crt" | ||
leader_client_key_file = "/opt/vault/tls/tls.key" | ||
} | ||
|
||
retry_join { | ||
leader_api_addr = "https://vault-1.vault-internal:8200" | ||
leader_ca_cert_file = "/opt/vault/tls/ca.crt" | ||
leader_client_cert_file = "/opt/vault/tls/tls.crt" | ||
leader_client_key_file = "/opt/vault/tls/tls.key" | ||
} | ||
|
||
retry_join { | ||
leader_api_addr = "https://vault-2.vault-internal:8200" | ||
leader_ca_cert_file = "/opt/vault/tls/ca.crt" | ||
leader_client_cert_file = "/opt/vault/tls/tls.crt" | ||
leader_client_key_file = "/opt/vault/tls/tls.key" | ||
} | ||
|
||
autopilot { | ||
cleanup_dead_servers = "true" | ||
last_contact_threshold = "10s" | ||
max_trailing_logs = 250000 | ||
min_quorum = 2 | ||
server_stabilization_time = "10s" | ||
} | ||
} | ||
|
||
ui: | ||
enabled: true | ||
serviceType: "LoadBalancer" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be |
||
targetPort: 8200 | ||
externalPort: 8200 | ||
|
||
injector: | ||
enabled: "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
# SA bound to the VSO namespace for transit engine auth | ||
namespace: vault | ||
name: vault-sa |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this certificate used for?