-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helm: use chunking release driver in systemNamespace
Signed-off-by: Joe Lanford <[email protected]>
- Loading branch information
1 parent
a0fca0d
commit 457fc3f
Showing
10 changed files
with
317 additions
and
44 deletions.
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
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 |
---|---|---|
@@ -1,10 +1,104 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: argocd | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: argocd-installer | ||
namespace: argocd | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: argocd-installer-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: argocd-installer-clusterrole | ||
subjects: | ||
- kind: ServiceAccount | ||
name: argocd-installer | ||
namespace: argocd | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: argocd-installer-clusterrole | ||
rules: | ||
- apiGroups: ["*"] | ||
resources: ["*"] | ||
verbs: ["*"] | ||
- apiGroups: [apiextensions.k8s.io] | ||
resources: [customresourcedefinitions] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: | ||
- appprojects.argoproj.io | ||
- argocds.argoproj.io | ||
- applications.argoproj.io | ||
- argocdexports.argoproj.io | ||
- applicationsets.argoproj.io | ||
- apiGroups: [rbac.authorization.k8s.io] | ||
resources: [clusterroles] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: | ||
- argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx | ||
- argocd-operator-metrics-reader | ||
- argocd-operator.v0-22gmilmgp91wu25is5i2ec598hni8owq3l71bbkl7iz3 | ||
- apiGroups: [rbac.authorization.k8s.io] | ||
resources: [clusterrolebindings] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: | ||
- argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx | ||
- argocd-operator.v0-22gmilmgp91wu25is5i2ec598hni8owq3l71bbkl7iz3 | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: argocd-installer-role | ||
namespace: argocd | ||
rules: | ||
- apiGroups: [""] | ||
resources: [serviceaccounts] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: [argocd-operator-controller-manager] | ||
- apiGroups: [""] | ||
resources: [configmaps] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: [argocd-operator-manager-config] | ||
- apiGroups: [""] | ||
resources: [services] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: [argocd-operator-controller-manager-metrics-service] | ||
- apiGroups: [apps] | ||
resources: [deployments] | ||
verbs: [get, list, watch, create, update, patch, delete] | ||
resourceNames: [argocd-operator-controller-manager] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: argocd-installer-binding | ||
namespace: argocd | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: argocd-installer-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: argocd-installer | ||
namespace: argocd | ||
--- | ||
apiVersion: olm.operatorframework.io/v1alpha1 | ||
kind: ClusterExtension | ||
metadata: | ||
name: clusterextension-sample | ||
name: argocd | ||
spec: | ||
installNamespace: default | ||
installNamespace: argocd | ||
packageName: argocd-operator | ||
version: 0.6.0 | ||
serviceAccount: | ||
name: default | ||
name: argocd-installer | ||
--- |
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,58 @@ | ||
package action | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/client-go/rest" | ||
"net/http" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" | ||
|
||
ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" | ||
"github.com/operator-framework/operator-controller/internal/authentication" | ||
) | ||
|
||
func ServiceAccountRestConfigMapper(tokenGetter *authentication.TokenGetter) helmclient.ObjectToRestConfigMapper { | ||
return func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) { | ||
cExt := o.(*ocv1alpha1.ClusterExtension) | ||
saKey := types.NamespacedName{ | ||
Name: cExt.Spec.ServiceAccount.Name, | ||
Namespace: cExt.Spec.InstallNamespace, | ||
} | ||
saConfig := rest.AnonymousClientConfig(c) | ||
saConfig.Wrap(func(rt http.RoundTripper) http.RoundTripper { | ||
return &bearerTokenInjectingTransport{ | ||
tokenGetter: tokenGetter, | ||
saKey: saKey, | ||
transport: rt, | ||
} | ||
}) | ||
return saConfig, nil | ||
} | ||
} | ||
|
||
type bearerTokenInjectingTransport struct { | ||
tokenGetter *authentication.TokenGetter | ||
saKey types.NamespacedName | ||
transport http.RoundTripper | ||
} | ||
|
||
func (t *bearerTokenInjectingTransport) RoundTrip(req *http.Request) (*http.Response, error) { | ||
resp, err := t.do(req) | ||
if resp != nil && resp.StatusCode == http.StatusUnauthorized { | ||
t.tokenGetter.Delete(t.saKey) | ||
resp, err = t.do(req) | ||
} | ||
return resp, err | ||
} | ||
|
||
func (t *bearerTokenInjectingTransport) do(req *http.Request) (*http.Response, error) { | ||
token, err := t.tokenGetter.Get(req.Context(), t.saKey) | ||
if err != nil { | ||
return nil, err | ||
} | ||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) | ||
return t.transport.RoundTrip(req) | ||
} |
Oops, something went wrong.