Skip to content

Commit

Permalink
Fixing restConfigs (#1111)
Browse files Browse the repository at this point in the history
* Fixing restConfigs

* Updating changelog
  • Loading branch information
ljakimczuk committed Mar 5, 2024
1 parent 4bca9cc commit 38f8e62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

## [Unreleased]

### Fixed

- Use separate rest configs for different Kubernetes clients.

## [3.2.0] - 2024-02-27

### Added
Expand Down
12 changes: 7 additions & 5 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func New(config Config) (*Service, error) {
}

var err error
var restConfig *rest.Config
var restConfigPrv *rest.Config
{
c := k8srestconfig.Config{
Logger: config.Logger,
Expand All @@ -81,12 +81,14 @@ func New(config Config) (*Service, error) {
},
}

restConfig, err = k8srestconfig.New(c)
restConfigPrv, err = k8srestconfig.New(c)
if err != nil {
return nil, microerror.Mask(err)
}
}

restConfigPub := rest.CopyConfig(restConfigPrv)

fs := afero.NewOsFs()

// k8sPrvClient runs under the chart-operator default permissions and hence
Expand All @@ -95,7 +97,7 @@ func New(config Config) (*Service, error) {
var k8sPrvClient k8sclient.Interface
var prvHelmClient helmclient.Interface
{
k8sPrvClient, err = newK8sClient(config, restConfig)
k8sPrvClient, err = newK8sClient(config, restConfigPrv)
if err != nil {
return nil, microerror.Mask(err)
}
Expand All @@ -119,15 +121,15 @@ func New(config Config) (*Service, error) {
// User "system:serviceaccount:default:automation" cannot create resource
// "rolebindings" in API group "rbac.authorization.k8s.io" in the namespace
// "giantswarm".
restConfig.Impersonate = rest.ImpersonationConfig{
restConfigPub.Impersonate = rest.ImpersonationConfig{
UserName: fmt.Sprintf(
"system:serviceaccount:%s:%s",
publicClientSANamespace,
publicClientSAName,
),
}

k8sPubClient, err = newK8sClient(config, restConfig)
k8sPubClient, err = newK8sClient(config, restConfigPub)
if err != nil {
return nil, microerror.Mask(err)
}
Expand Down

0 comments on commit 38f8e62

Please sign in to comment.