forked from upbound/crossplane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from turkenh/port-provider-identity
Reimplement alpha provider identity support
- Loading branch information
Showing
7 changed files
with
142 additions
and
1 deletion.
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
32 changes: 32 additions & 0 deletions
32
internal/controller/pkg/revision/uxp_runtime_override_options.go
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,32 @@ | ||
package revision | ||
|
||
import ( | ||
"github.com/aws/smithy-go/ptr" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
// DeploymentWithUpboundProviderIdentity mounts the Upbound Provider Identity | ||
// CSI driver as a volume to the runtime container of a Deployment. | ||
func DeploymentWithUpboundProviderIdentity() DeploymentOverride { | ||
proidcVolumeName := "proidc" | ||
proidcDriverName := "proidc.csi.upbound.io" | ||
proidcMountPath := "/var/run/secrets/upbound.io/provider" | ||
|
||
return func(d *appsv1.Deployment) { | ||
d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, corev1.Volume{ | ||
Name: proidcVolumeName, | ||
VolumeSource: corev1.VolumeSource{ | ||
CSI: &corev1.CSIVolumeSource{ | ||
Driver: proidcDriverName, | ||
ReadOnly: ptr.Bool(true), | ||
}, | ||
}, | ||
}) | ||
d.Spec.Template.Spec.Containers[0].VolumeMounts = append(d.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ | ||
Name: proidcVolumeName, | ||
ReadOnly: true, | ||
MountPath: proidcMountPath, | ||
}) | ||
} | ||
} |
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,70 @@ | ||
/* | ||
Copyright 2023 The Crossplane Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package revision | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
appsv1 "k8s.io/api/apps/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
pkgmetav1 "github.com/crossplane/crossplane/apis/pkg/meta/v1" | ||
) | ||
|
||
func TestUXPRuntimeManifestBuilderDeployment(t *testing.T) { | ||
type args struct { | ||
builder ManifestBuilder | ||
overrides []DeploymentOverride | ||
serviceAccountName string | ||
} | ||
type want struct { | ||
want *appsv1.Deployment | ||
} | ||
cases := map[string]struct { | ||
reason string | ||
args args | ||
want want | ||
}{ | ||
"ProviderDeploymentWithProviderIdentity": { | ||
reason: "If provider identity is enabled, a proidc volume should be added.", | ||
args: args{ | ||
builder: &RuntimeManifestBuilder{ | ||
revision: providerRevision, | ||
namespace: namespace, | ||
providerIdentity: true, | ||
}, | ||
serviceAccountName: providerRevisionName, | ||
overrides: providerDeploymentOverrides(&pkgmetav1.Provider{ObjectMeta: metav1.ObjectMeta{Name: providerMetaName}}, providerRevision), | ||
}, | ||
want: want{ | ||
want: deploymentProvider(providerName, providerRevisionName, providerImage, DeploymentWithSelectors(map[string]string{ | ||
"pkg.crossplane.io/provider": providerMetaName, | ||
"pkg.crossplane.io/revision": providerRevisionName, | ||
}), DeploymentWithUpboundProviderIdentity()), | ||
}, | ||
}, | ||
} | ||
for name, tc := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
got := tc.args.builder.Deployment(tc.args.serviceAccountName, tc.args.overrides...) | ||
if diff := cmp.Diff(tc.want.want, got); diff != "" { | ||
t.Errorf("\n%s\nDeployment(...): -want, +got:\n%s\n", tc.reason, diff) | ||
} | ||
}) | ||
} | ||
} |
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,10 @@ | ||
package features | ||
|
||
import "github.com/crossplane/crossplane-runtime/pkg/feature" | ||
|
||
// Alpha Feature flags. | ||
const ( | ||
// EnableProviderIdentity enables alpha support for Provider identity. This | ||
// feature is only available when running on Upbound. | ||
EnableProviderIdentity feature.Flag = "EnableProviderIdentity" | ||
) |