Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
01af5fd
General: Vault authentication via cross-namespace service accounts
BojanZelic Dec 24, 2024
cc92f15
Merge branch 'main' of github.com:kedacore/keda into keda-vault-servi…
BojanZelic Dec 24, 2024
097fec2
General: Vault authentication via cross-namespace service accounts
BojanZelic Dec 24, 2024
a141b41
General: Vault authentication via cross-namespace service accounts
BojanZelic Dec 24, 2024
95e7c47
General: Vault authentication via cross-namespace service accounts
BojanZelic Dec 24, 2024
bfa2613
add e2e test
BojanZelic Dec 31, 2024
8a10636
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Jan 10, 2025
c45451e
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Jan 14, 2025
c739b06
Merge branch 'main' of github.com:kedacore/keda into keda-vault-servi…
BojanZelic Mar 12, 2025
0b987a1
Merge branch 'main' of github.com:kedacore/keda into keda-vault-servi…
BojanZelic Apr 3, 2025
2fd6cdb
combine logic to retreive service account tokens
BojanZelic Apr 4, 2025
3425928
Merge branch 'keda-vault-service-account-token-request' of bojan-gith…
BojanZelic Apr 4, 2025
a4aedcb
combine logic to retreive service account tokens
BojanZelic Apr 4, 2025
21fa360
combine logic to retreive service account tokens
BojanZelic Apr 4, 2025
8d5b53f
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Apr 14, 2025
b7dda61
Update CHANGELOG.md
BojanZelic Apr 14, 2025
3cdfba3
Update pkg/scaling/resolver/hashicorpvault_handler.go
BojanZelic Apr 15, 2025
f414b39
Rename patch_operator.yaml to patch_operator.yml
BojanZelic Apr 15, 2025
527795e
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Apr 15, 2025
2b186b2
Merge branch 'main' of github.com:kedacore/keda into keda-vault-servi…
BojanZelic Jul 2, 2025
96a10e9
Merge branch 'keda-vault-service-account-token-request' of bojan-gith…
BojanZelic Jul 2, 2025
2a90e3c
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Jul 21, 2025
e66777c
fix order of changelog
BojanZelic Jul 21, 2025
83ff9ff
Merge branch 'main' into keda-vault-service-account-token-request
zroubalik Aug 19, 2025
ca6dae2
Merge branch 'main' into keda-vault-service-account-token-request
BojanZelic Sep 2, 2025
b9c1e1c
Merge branch 'main' of github.com:kedacore/keda into keda-vault-servi…
BojanZelic Sep 10, 2025
9104300
Merge branch 'keda-vault-service-account-token-request' of bojan-gith…
BojanZelic Sep 10, 2025
c82ebb4
Update CHANGELOG.md
BojanZelic Sep 10, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### New

- **General**: Vault authentication via cross-namespace service accounts ([#6153](https://github.com/kedacore/keda/issues/6153))
- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

#### Experimental
Expand Down
3 changes: 3 additions & 0 deletions apis/keda/v1alpha1/triggerauthentication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ type Credential struct {

// +optional
ServiceAccount string `json:"serviceAccount,omitempty"`

// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

// VaultAuthentication contains the list of Hashicorp Vault authentication methods
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/keda.sh_clustertriggerauthentications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ spec:
properties:
serviceAccount:
type: string
serviceAccountName:
type: string
token:
type: string
type: object
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/keda.sh_triggerauthentications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ spec:
properties:
serviceAccount:
type: string
serviceAccountName:
type: string
token:
type: string
type: object
Expand Down
File renamed without changes.
38 changes: 25 additions & 13 deletions pkg/scaling/resolver/hashicorpvault_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,35 @@ limitations under the License.
package resolver

import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"strings"

"github.com/go-logr/logr"
vaultapi "github.com/hashicorp/vault/api"
"github.com/pkg/errors"

kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/kedacore/keda/v2/pkg/scalers/authentication"
)

// HashicorpVaultHandler is specification of Hashi Corp Vault
type HashicorpVaultHandler struct {
vault *kedav1alpha1.HashiCorpVault
client *vaultapi.Client
stopCh chan struct{}
vault *kedav1alpha1.HashiCorpVault
client *vaultapi.Client
acs *authentication.AuthClientSet
namespace string
stopCh chan struct{}
}

// NewHashicorpVaultHandler creates a HashicorpVaultHandler object
func NewHashicorpVaultHandler(v *kedav1alpha1.HashiCorpVault) *HashicorpVaultHandler {
func NewHashicorpVaultHandler(v *kedav1alpha1.HashiCorpVault, acs *authentication.AuthClientSet, namespace string) *HashicorpVaultHandler {
return &HashicorpVaultHandler{
vault: v,
vault: v,
acs: acs,
namespace: namespace,
}
}

Expand Down Expand Up @@ -88,6 +94,8 @@ func (vh *HashicorpVaultHandler) Initialize(logger logr.Logger) error {
// token Extract a vault token from the Authentication method
func (vh *HashicorpVaultHandler) token(client *vaultapi.Client) (string, error) {
var token string
var jwt []byte
var err error

switch vh.vault.Authentication {
case kedav1alpha1.VaultAuthenticationToken:
Expand Down Expand Up @@ -116,23 +124,27 @@ func (vh *HashicorpVaultHandler) token(client *vaultapi.Client) (string, error)
vh.vault.Credential = &defaultCred
}

if len(vh.vault.Credential.ServiceAccount) == 0 {
return token, errors.New("k8s SA file not in config")
if vh.vault.Credential.ServiceAccountName == "" && len(vh.vault.Credential.ServiceAccount) == 0 {
return token, errors.New("k8s SA file not in config or serviceAccountName not supplied")
}

// Get the JWT from POD
jwt, err := os.ReadFile(vh.vault.Credential.ServiceAccount)
if err != nil {
return token, err
if vh.vault.Credential.ServiceAccountName != "" {
jwt = []byte(GenerateBoundServiceAccountToken(context.Background(), vh.vault.Credential.ServiceAccountName, vh.namespace, vh.acs))
} else if len(vh.vault.Credential.ServiceAccount) != 0 {
// Get the JWT from POD
jwt, err = os.ReadFile(vh.vault.Credential.ServiceAccount)
if err != nil {
return token, err
}
}

data := map[string]interface{}{"jwt": string(jwt), "role": vh.vault.Role}
secret, err := client.Logical().Write(fmt.Sprintf("auth/%s/login", vh.vault.Mount), data)
if err != nil {
return token, err
}

token = secret.Auth.ClientToken

default:
return token, fmt.Errorf("vault auth method %s is not supported", vh.vault.Authentication)
}
Expand Down
Loading
Loading