feat: Automatically create the container build SCC if containerBuildC… (#1542)

* feat: Automatically create the container build SCC if containerBuildCapability is enabled

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1545/head
Anatolii Bazko 2022-10-18 10:07:01 +03:00 committed by GitHub
parent 774f8bf4e9
commit 21b652e2c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 7900 additions and 16 deletions

View File

@ -262,6 +262,9 @@ gen-chectl-tmpl: ## Generate Eclipse Che k8s deployment resources used by chectl
if [[ -f $${src}/org.eclipse.che.ValidatingWebhookConfiguration.yaml ]]; then
cp $${src}/org.eclipse.che.ValidatingWebhookConfiguration.yaml $${cheOperatorDst}/org.eclipse.che.ValidatingWebhookConfiguration.yaml
fi
if [[ -f $${src}/org.eclipse.che.MutatingWebhookConfiguration.yaml ]]; then
cp $${src}/org.eclipse.che.MutatingWebhookConfiguration.yaml $${cheOperatorDst}/org.eclipse.che.MutatingWebhookConfiguration.yaml
fi
cp $${src}/che-operator-serving-cert.Certificate.yaml $${cheOperatorDst}/serving-cert.yaml
cp $${src}/che-operator-selfsigned-issuer.Issuer.yaml $${cheOperatorDst}/selfsigned-issuer.yaml
@ -351,6 +354,7 @@ install-che-operands: generate manifests download-kustomize download-gateway-res
# Disable Webhooks since che operator pod is scaled down
$(K8S_CLI) delete validatingwebhookconfiguration org.eclipse.che
$(K8S_CLI) delete mutatingwebhookconfiguration org.eclipse.che
$(K8S_CLI) patch crd checlusters.org.eclipse.che --patch '{"spec": {"conversion": null}}' --type=merge
$(MAKE) store_tls_cert

View File

@ -26,6 +26,7 @@ resources:
version: v2
webhooks:
conversion: true
defaulting: true
validation: true
webhookVersion: v1
version: "3"

View File

@ -111,6 +111,9 @@ type CheClusterDevEnvironments struct {
// +optional
// +kubebuilder:default:=true
DisableContainerBuildCapabilities *bool `json:"disableContainerBuildCapabilities,omitempty"`
// Container build configuration.
// +optional
ContainerBuildConfiguration *ContainerBuildConfiguration `json:"containerBuildConfiguration,omitempty"`
}
// Che components configuration.
@ -628,6 +631,14 @@ type BitBucketService struct {
Endpoint string `json:"endpoint,omitempty"`
}
// Container build configuration.
type ContainerBuildConfiguration struct {
// OpenShift security context constraint to build containers.
// +kubebuilder:validation:Required
// +kubebuilder:default:=container-build
OpenShiftSecurityContextConstraint string `json:"openShiftSecurityContextConstraint,omitempty"`
}
// GatewayPhase describes the different phases of the Che gateway lifecycle.
type GatewayPhase string
@ -797,3 +808,11 @@ func (c *CheCluster) GetIdentityToken() string {
func (c *CheCluster) IsAccessTokenConfigured() bool {
return c.GetIdentityToken() == constants.AccessToken
}
func (c *CheCluster) IsContainerBuildCapabilitiesEnabled() bool {
return c.Spec.DevEnvironments.DisableContainerBuildCapabilities != nil && !*c.Spec.DevEnvironments.DisableContainerBuildCapabilities
}
func (c *CheCluster) IsOpenShiftSecurityContextConstraintSet() bool {
return c.Spec.DevEnvironments.ContainerBuildConfiguration != nil && c.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint != ""
}

View File

@ -40,6 +40,15 @@ func (r *CheCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
Complete()
}
var _ webhook.Defaulter = &CheCluster{}
// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *CheCluster) Default() {
if r.IsContainerBuildCapabilitiesEnabled() && r.Spec.DevEnvironments.ContainerBuildConfiguration == nil {
r.Spec.DevEnvironments.ContainerBuildConfiguration = &ContainerBuildConfiguration{}
}
}
var _ webhook.Validator = &CheCluster{}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type

View File

@ -181,6 +181,11 @@ func (in *CheClusterDevEnvironments) DeepCopyInto(out *CheClusterDevEnvironments
*out = new(bool)
**out = **in
}
if in.ContainerBuildConfiguration != nil {
in, out := &in.ContainerBuildConfiguration, &out.ContainerBuildConfiguration
*out = new(ContainerBuildConfiguration)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CheClusterDevEnvironments.
@ -391,6 +396,21 @@ func (in *Container) DeepCopy() *Container {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ContainerBuildConfiguration) DeepCopyInto(out *ContainerBuildConfiguration) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerBuildConfiguration.
func (in *ContainerBuildConfiguration) DeepCopy() *ContainerBuildConfiguration {
if in == nil {
return nil
}
out := new(ContainerBuildConfiguration)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Dashboard) DeepCopyInto(out *Dashboard) {
*out = *in

View File

@ -77,7 +77,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.55.0-699.next
name: eclipse-che-preview-openshift.v7.56.0-707.next
namespace: placeholder
spec:
apiservicedefinitions: {}
@ -863,6 +863,15 @@ spec:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update
serviceAccountName: che-operator
deployments:
- name: che-operator
@ -1230,7 +1239,7 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.55.0-699.next
version: 7.56.0-707.next
webhookdefinitions:
- admissionReviewVersions:
- v1
@ -1253,6 +1262,27 @@ spec:
targetPort: 9443
type: ValidatingAdmissionWebhook
webhookPath: /validate-org-eclipse-che-v2-checluster
- admissionReviewVersions:
- v1
- v1beta1
containerPort: 443
deploymentName: che-operator
failurePolicy: Fail
generateName: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None
targetPort: 9443
type: MutatingAdmissionWebhook
webhookPath: /mutate-org-eclipse-che-v2-checluster
- admissionReviewVersions:
- v1
- v2

View File

@ -5414,6 +5414,15 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build
containers.
type: string
type: object
defaultComponents:
default:
- container:

View File

@ -5275,6 +5275,15 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build
containers.
type: string
type: object
defaultComponents:
default:
- container:

View File

@ -9,7 +9,14 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: org.eclipse.che
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:

View File

@ -391,4 +391,13 @@ rules:
resources:
- subjectaccessreviews
verbs:
- create
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update

View File

@ -9,7 +9,39 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: org.eclipse.che
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:

View File

@ -15,9 +15,11 @@ package che
import (
"context"
"github.com/eclipse-che/che-operator/pkg/common/test"
containerbuild "github.com/eclipse-che/che-operator/pkg/deploy/container-build"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/test"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
"github.com/eclipse-che/che-operator/pkg/deploy/consolelink"
@ -114,6 +116,7 @@ func NewReconciler(
reconcileManager.RegisterReconciler(dashboard.NewDashboardReconciler())
reconcileManager.RegisterReconciler(gateway.NewGatewayReconciler())
reconcileManager.RegisterReconciler(server.NewCheServerReconciler())
reconcileManager.RegisterReconciler(containerbuild.NewContainerBuildReconciler())
if infrastructure.IsOpenShift() {
reconcileManager.RegisterReconciler(consolelink.NewConsoleLinkReconciler())

View File

@ -3616,6 +3616,14 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build containers.
type: string
type: object
defaultComponents:
default:
- container:
@ -5612,6 +5620,15 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
@ -5866,6 +5883,40 @@ spec:
selfSigned: {}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: eclipse-che/che-operator-serving-cert
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
name: org.eclipse.che
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
annotations:

View File

@ -392,3 +392,12 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update

View File

@ -3611,6 +3611,14 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build containers.
type: string
type: object
defaultComponents:
default:
- container:

View File

@ -0,0 +1,45 @@
#
# Copyright (c) 2019-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: eclipse-che/che-operator-serving-cert
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
name: org.eclipse.che
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None

View File

@ -3616,6 +3616,14 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build containers.
type: string
type: object
defaultComponents:
default:
- container:
@ -5612,6 +5620,15 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
@ -5833,6 +5850,38 @@ spec:
secretName: che-operator-webhook-server-cert
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
name: org.eclipse.che
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
annotations:

View File

@ -392,3 +392,12 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update

View File

@ -3611,6 +3611,14 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build containers.
type: string
type: object
defaultComponents:
default:
- container:

View File

@ -0,0 +1,43 @@
#
# Copyright (c) 2019-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
name: org.eclipse.che
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None

View File

@ -3611,6 +3611,14 @@ spec:
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
containerBuildConfiguration:
description: Container build configuration.
properties:
openShiftSecurityContextConstraint:
default: container-build
description: OpenShift security context constraint to build containers.
type: string
type: object
defaultComponents:
default:
- container:

View File

@ -392,3 +392,12 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- get
- create
- delete
- update

View File

@ -0,0 +1,45 @@
#
# Copyright (c) 2019-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: eclipse-che/che-operator-serving-cert
labels:
app.kubernetes.io/component: che-operator
app.kubernetes.io/instance: che
app.kubernetes.io/name: che
app.kubernetes.io/part-of: che.eclipse.org
name: org.eclipse.che
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: che-operator-service
namespace: eclipse-che
path: /mutate-org-eclipse-che-v2-checluster
failurePolicy: Fail
name: mchecluster.kb.io
rules:
- apiGroups:
- org.eclipse.che
apiVersions:
- v2
operations:
- CREATE
- UPDATE
resources:
- checlusters
sideEffects: None

View File

@ -17,6 +17,8 @@ import (
"os"
"time"
securityv1 "github.com/openshift/api/security/v1"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
devworkspaceinfra "github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/constants"
@ -149,6 +151,7 @@ func init() {
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(consolev1.AddToScheme(scheme))
utilruntime.Must(projectv1.AddToScheme(scheme))
utilruntime.Must(securityv1.Install(scheme))
}
}

View File

@ -92,7 +92,6 @@ const (
CheEclipseOrgNamespace = "che.eclipse.org/namespace"
CheEclipseOrgOAuthScmServer = "che.eclipse.org/oauth-scm-server"
CheEclipseOrgScmServerEndpoint = "che.eclipse.org/scm-server-endpoint"
CheEclipseOrgHash256 = "che.eclipse.org/hash256"
CheEclipseOrgManagedAnnotationsDigest = "che.eclipse.org/managed-annotations-digest"
// DevEnvironments
@ -118,7 +117,6 @@ const (
DevfileRegistryName = "devfile-registry"
PluginRegistryName = "plugin-registry"
PostgresName = "postgres"
DevWorkspaceController = "devworkspace-controller"
GatewayContainerName = "gateway"
GatewayConfigSideCarContainerName = "configbump"
GatewayAuthenticationContainerName = "oauth-proxy"
@ -126,8 +124,10 @@ const (
// common
CheEclipseOrg = "che.eclipse.org"
DevWorkspaceOperator = "devworkspace-operator"
InstallOrUpdateFailed = "InstallOrUpdateFailed"
// DevWorkspace
DevWorkspaceServiceAccountName = "devworkspace-controller-serviceaccount"
)
var (

View File

@ -17,6 +17,8 @@ import (
"strings"
"testing"
securityv1 "github.com/openshift/api/security/v1"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
@ -182,6 +184,7 @@ func GetDeployContext(cheCluster *chev2.CheCluster, initObjs []runtime.Object) *
scheme.AddKnownTypes(corev1.SchemeGroupVersion, &corev1.Secret{})
scheme.AddKnownTypes(corev1.SchemeGroupVersion, &corev1.Secret{})
scheme.AddKnownTypes(console.GroupVersion, &console.ConsoleLink{})
securityv1.Install(scheme)
initObjs = append(initObjs, cheCluster)
cli := fake.NewFakeClientWithScheme(scheme, initObjs...)

View File

@ -23,7 +23,6 @@ import (
var crDiffOpts = cmp.Options{
cmpopts.IgnoreFields(rbac.ClusterRole{}, "TypeMeta", "ObjectMeta"),
cmpopts.IgnoreFields(rbac.PolicyRule{}, "ResourceNames", "NonResourceURLs"),
}
func SyncClusterRoleToCluster(

View File

@ -34,7 +34,18 @@ func SyncClusterRoleBindingToCluster(
serviceAccountName string,
clusterRoleName string) (bool, error) {
crbSpec := getClusterRoleBindingSpec(deployContext, name, serviceAccountName, clusterRoleName)
crbSpec := getClusterRoleBindingSpec(deployContext, name, serviceAccountName, deployContext.CheCluster.Namespace, clusterRoleName)
return Sync(deployContext, crbSpec, crbDiffOpts)
}
func SyncClusterRoleBindingToClusterInGivenNamespace(
deployContext *chetypes.DeployContext,
name string,
serviceAccountName string,
serviceAccountNamespace string,
clusterRoleName string) (bool, error) {
crbSpec := getClusterRoleBindingSpec(deployContext, name, serviceAccountName, serviceAccountNamespace, clusterRoleName)
return Sync(deployContext, crbSpec, crbDiffOpts)
}
@ -45,7 +56,7 @@ func SyncClusterRoleBindingAndAddFinalizerToCluster(
clusterRoleName string) (bool, error) {
finalizer := GetFinalizerName(strings.ToLower(name) + ".crb")
crbSpec := getClusterRoleBindingSpec(deployContext, name, serviceAccountName, clusterRoleName)
crbSpec := getClusterRoleBindingSpec(deployContext, name, serviceAccountName, deployContext.CheCluster.Namespace, clusterRoleName)
return SyncAndAddFinalizer(deployContext, crbSpec, crbDiffOpts, finalizer)
}
@ -75,7 +86,8 @@ func getClusterRoleBindingSpec(
deployContext *chetypes.DeployContext,
name string,
serviceAccountName string,
roleName string) *rbac.ClusterRoleBinding {
serviceAccountNamespace string,
clusterRoleName string) *rbac.ClusterRoleBinding {
labels := GetLabels(defaults.GetCheFlavor())
clusterRoleBinding := &rbac.ClusterRoleBinding{
@ -94,11 +106,11 @@ func getClusterRoleBindingSpec(
{
Kind: rbac.ServiceAccountKind,
Name: serviceAccountName,
Namespace: deployContext.CheCluster.Namespace,
Namespace: serviceAccountNamespace,
},
},
RoleRef: rbac.RoleRef{
Name: roleName,
Name: clusterRoleName,
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
},

View File

@ -0,0 +1,240 @@
//
// Copyright (c) 2019-2021 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//
// Contributors:
// Red Hat, Inc. - initial API and implementation
//
package containerbuild
import (
"context"
"fmt"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/constants"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/deploy"
securityv1 "github.com/openshift/api/security/v1"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
type ContainerBuildReconciler struct {
deploy.Reconcilable
}
func NewContainerBuildReconciler() *ContainerBuildReconciler {
return &ContainerBuildReconciler{}
}
func (cb *ContainerBuildReconciler) Reconcile(ctx *chetypes.DeployContext) (reconcile.Result, bool, error) {
if ctx.CheCluster.IsContainerBuildCapabilitiesEnabled() {
if ctx.CheCluster.IsOpenShiftSecurityContextConstraintSet() {
if done, err := cb.syncSCC(ctx); !done {
return reconcile.Result{}, false, err
}
if done, err := cb.syncRBAC(ctx); !done {
return reconcile.Result{}, false, err
}
if err := deploy.AppendFinalizer(ctx, cb.getFinalizerName()); err != nil {
return reconcile.Result{}, false, err
}
}
} else {
if done, err := cb.removeRBAC(ctx); !done {
return reconcile.Result{}, false, err
}
if done, err := cb.removeSCC(ctx); !done {
return reconcile.Result{}, false, err
}
if err := deploy.DeleteFinalizer(ctx, cb.getFinalizerName()); err != nil {
return reconcile.Result{}, false, err
}
}
return reconcile.Result{}, true, nil
}
func (cb *ContainerBuildReconciler) Finalize(ctx *chetypes.DeployContext) bool {
done := true
if done, err := cb.removeRBAC(ctx); !done {
done = false
logrus.Errorf("Failed to delete RBAC, cause: %v", err)
}
if done, err := cb.removeSCC(ctx); !done {
done = false
logrus.Errorf("Failed to delete SCC, cause: %v", err)
}
if err := deploy.DeleteFinalizer(ctx, cb.getFinalizerName()); err != nil {
done = false
logrus.Errorf("Failed to delete finalizer, cause: %v", err)
}
return done
}
func (cb *ContainerBuildReconciler) syncSCC(ctx *chetypes.DeployContext) (bool, error) {
if exists, err := deploy.GetClusterObject(
ctx,
ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint,
&securityv1.SecurityContextConstraints{},
); err != nil {
return false, nil
} else if exists {
// Don't override existed SCC
return true, nil
}
return deploy.Sync(ctx, cb.getSCCSpec(ctx))
}
func (cb *ContainerBuildReconciler) syncRBAC(ctx *chetypes.DeployContext) (bool, error) {
if done, err := deploy.SyncClusterRoleToCluster(ctx, cb.getClusterRoleName(), cb.getPolicyRules(ctx)); !done {
return false, err
}
if devWorkspaceServiceAccountNamespace, err := cb.getDevWorkspaceServiceAccountNamespace(ctx); devWorkspaceServiceAccountNamespace == "" {
return false, err
} else {
return deploy.SyncClusterRoleBindingToClusterInGivenNamespace(
ctx,
cb.getClusterRoleBindingName(),
constants.DevWorkspaceServiceAccountName,
devWorkspaceServiceAccountNamespace,
cb.getClusterRoleName())
}
}
func (cb *ContainerBuildReconciler) getDevWorkspaceServiceAccountNamespace(ctx *chetypes.DeployContext) (string, error) {
crb := &rbacv1.ClusterRoleBinding{}
if exists, err := deploy.GetClusterObject(ctx, cb.getClusterRoleBindingName(), crb); err != nil {
return "", err
} else if exists {
return crb.Subjects[0].Namespace, nil
} else {
sas := &corev1.ServiceAccountList{}
if err := ctx.ClusterAPI.NonCachingClient.List(context.TODO(), sas); err != nil {
return "", err
}
for _, sa := range sas.Items {
if sa.Name == constants.DevWorkspaceServiceAccountName {
return sa.Namespace, nil
}
}
}
return "", fmt.Errorf("ServiceAccount %s not found", constants.DevWorkspaceServiceAccountName)
}
func (cb *ContainerBuildReconciler) removeSCC(ctx *chetypes.DeployContext) (bool, error) {
if ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration == nil {
return true, nil
}
sccName := ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint
if sccName != "" {
scc := &securityv1.SecurityContextConstraints{}
if exists, err := deploy.GetClusterObject(ctx, sccName, scc); !exists {
return err == nil, err
}
if scc.Labels[constants.KubernetesManagedByLabelKey] == deploy.GetManagedByLabel() {
// Removes only if it is managed by operator
return deploy.DeleteClusterObject(ctx, sccName, &securityv1.SecurityContextConstraints{})
}
}
return true, nil
}
func (cb *ContainerBuildReconciler) removeRBAC(ctx *chetypes.DeployContext) (bool, error) {
if done, err := deploy.DeleteClusterObject(ctx, cb.getClusterRoleName(), &rbacv1.ClusterRole{}); !done {
return false, err
}
if done, err := deploy.DeleteClusterObject(ctx, cb.getClusterRoleBindingName(), &rbacv1.ClusterRoleBinding{}); !done {
return false, err
}
return true, nil
}
func (cb *ContainerBuildReconciler) getClusterRoleName() string {
return defaults.GetCheFlavor() + "-container-build-scc"
}
func (cb *ContainerBuildReconciler) getClusterRoleBindingName() string {
return defaults.GetCheFlavor() + "-container-build-scc"
}
func (cb *ContainerBuildReconciler) getFinalizerName() string {
return "container-build.finalizers.che.eclipse.org"
}
func (cb *ContainerBuildReconciler) getPolicyRules(ctx *chetypes.DeployContext) []rbacv1.PolicyRule {
return []rbacv1.PolicyRule{
{
APIGroups: []string{"security.openshift.io"},
Resources: []string{"securitycontextconstraints"},
ResourceNames: []string{ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint},
Verbs: []string{"get", "update"},
},
}
}
func (cb *ContainerBuildReconciler) getSCCSpec(ctx *chetypes.DeployContext) *securityv1.SecurityContextConstraints {
return &securityv1.SecurityContextConstraints{
TypeMeta: metav1.TypeMeta{
Kind: "SecurityContextConstraints",
APIVersion: securityv1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint,
Labels: deploy.GetLabels(defaults.GetCheFlavor()),
},
AllowHostDirVolumePlugin: false,
AllowHostIPC: false,
AllowHostNetwork: false,
AllowHostPID: false,
AllowHostPorts: false,
AllowPrivilegeEscalation: pointer.BoolPtr(true),
AllowPrivilegedContainer: false,
AllowedCapabilities: []corev1.Capability{"SETUID", "SETGID"},
DefaultAddCapabilities: nil,
FSGroup: securityv1.FSGroupStrategyOptions{Type: securityv1.FSGroupStrategyMustRunAs},
// Temporary workaround for https://github.com/devfile/devworkspace-operator/issues/884
Priority: pointer.Int32Ptr(20),
ReadOnlyRootFilesystem: false,
RequiredDropCapabilities: []corev1.Capability{"KILL", "MKNOD"},
RunAsUser: securityv1.RunAsUserStrategyOptions{Type: securityv1.RunAsUserStrategyMustRunAsRange},
SELinuxContext: securityv1.SELinuxContextStrategyOptions{Type: securityv1.SELinuxStrategyMustRunAs},
SupplementalGroups: securityv1.SupplementalGroupsStrategyOptions{Type: securityv1.SupplementalGroupsStrategyRunAsAny},
Users: []string{},
Groups: []string{},
Volumes: []securityv1.FSType{
securityv1.FSTypeConfigMap,
securityv1.FSTypeDownwardAPI,
securityv1.FSTypeEmptyDir,
securityv1.FSTypePersistentVolumeClaim,
securityv1.FSProjected,
securityv1.FSTypeSecret,
},
}
}

View File

@ -0,0 +1,164 @@
//
// Copyright (c) 2019-2021 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//
// Contributors:
// Red Hat, Inc. - initial API and implementation
//
package containerbuild
import (
chev2 "github.com/eclipse-che/che-operator/api/v2"
"github.com/eclipse-che/che-operator/pkg/common/constants"
"github.com/eclipse-che/che-operator/pkg/common/test"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
securityv1 "github.com/openshift/api/security/v1"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"testing"
)
func TestContainerBuildReconciler(t *testing.T) {
dwSA := &corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
Kind: "ServiceAccount",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: constants.DevWorkspaceServiceAccountName,
Namespace: "eclipse-che",
},
}
ctx := test.GetDeployContext(nil, []runtime.Object{dwSA})
containerBuildReconciler := NewContainerBuildReconciler()
_, done, err := containerBuildReconciler.Reconcile(ctx)
assert.True(t, done)
assert.Nil(t, err)
// Enable Container build capabilities
ctx.CheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.BoolPtr(false)
ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration = &chev2.ContainerBuildConfiguration{OpenShiftSecurityContextConstraint: "scc"}
_, done, err = containerBuildReconciler.Reconcile(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "scc"}, &securityv1.SecurityContextConstraints{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleName()}, &rbacv1.ClusterRole{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleBindingName()}, &rbacv1.ClusterRoleBinding{}))
assert.True(t, utils.Contains(ctx.CheCluster.Finalizers, containerBuildReconciler.getFinalizerName()))
// Disable Container build capabilities
ctx.CheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.BoolPtr(true)
_, done, err = containerBuildReconciler.Reconcile(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "scc"}, &securityv1.SecurityContextConstraints{}))
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleName()}, &rbacv1.ClusterRole{}))
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleBindingName()}, &rbacv1.ClusterRoleBinding{}))
assert.False(t, utils.Contains(ctx.CheCluster.Finalizers, containerBuildReconciler.getFinalizerName()))
}
func TestSyncAndRemoveRBAC(t *testing.T) {
dwSA := &corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
Kind: "ServiceAccount",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: constants.DevWorkspaceServiceAccountName,
Namespace: "eclipse-che",
},
}
ctx := test.GetDeployContext(nil, []runtime.Object{dwSA})
ctx.CheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.BoolPtr(false)
ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration = &chev2.ContainerBuildConfiguration{OpenShiftSecurityContextConstraint: "scc"}
containerBuildReconciler := NewContainerBuildReconciler()
done, err := containerBuildReconciler.syncRBAC(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleName()}, &rbacv1.ClusterRole{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleBindingName()}, &rbacv1.ClusterRoleBinding{}))
done, err = containerBuildReconciler.removeRBAC(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleName()}, &rbacv1.ClusterRole{}))
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: containerBuildReconciler.getClusterRoleBindingName()}, &rbacv1.ClusterRoleBinding{}))
}
func TestSyncAndRemoveSCC(t *testing.T) {
ctx := test.GetDeployContext(nil, []runtime.Object{})
ctx.CheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.BoolPtr(false)
ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration = &chev2.ContainerBuildConfiguration{OpenShiftSecurityContextConstraint: "scc"}
containerBuildReconciler := NewContainerBuildReconciler()
done, err := containerBuildReconciler.syncSCC(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "scc"}, &securityv1.SecurityContextConstraints{}))
done, err = containerBuildReconciler.removeSCC(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.False(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "scc"}, &securityv1.SecurityContextConstraints{}))
}
func TestShouldNotSyncSCCIfAlreadyExists(t *testing.T) {
scc := &securityv1.SecurityContextConstraints{
TypeMeta: metav1.TypeMeta{
Kind: "SecurityContextConstraints",
APIVersion: securityv1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "scc",
},
}
ctx := test.GetDeployContext(nil, []runtime.Object{scc})
ctx.CheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.BoolPtr(false)
ctx.CheCluster.Spec.DevEnvironments.ContainerBuildConfiguration = &chev2.ContainerBuildConfiguration{OpenShiftSecurityContextConstraint: "scc"}
containerBuildReconciler := NewContainerBuildReconciler()
done, err := containerBuildReconciler.syncSCC(ctx)
assert.True(t, done)
assert.Nil(t, err)
scc = &securityv1.SecurityContextConstraints{}
exists, err := deploy.GetClusterObject(ctx, "scc", scc)
assert.True(t, exists)
assert.Nil(t, err)
// No labels must be added
assert.True(t, scc.Labels[deploy.GetManagedByLabel()] == "")
done, err = containerBuildReconciler.removeSCC(ctx)
assert.True(t, done)
assert.Nil(t, err)
// Can't be removed
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "scc"}, &securityv1.SecurityContextConstraints{}))
}

View File

@ -0,0 +1,26 @@
//
// Copyright (c) 2019-2021 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//
// Contributors:
// Red Hat, Inc. - initial API and implementation
//
package containerbuild
import (
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/test"
)
func init() {
test.EnableTestMode()
infrastructure.InitializeForTesting(infrastructure.OpenShiftv4)
defaults.Initialize("../../../config/manager/manager.yaml")
}

View File

@ -22,10 +22,14 @@ func GetLabels(component string) map[string]string {
constants.KubernetesInstanceLabelKey: defaults.GetCheFlavor(),
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: component,
constants.KubernetesManagedByLabelKey: defaults.GetCheFlavor() + "-operator",
constants.KubernetesManagedByLabelKey: GetManagedByLabel(),
}
}
func GetManagedByLabel() string {
return defaults.GetCheFlavor() + "-operator"
}
func GetLabelsAndSelector(component string) (map[string]string, map[string]string) {
labels := GetLabels(component)
legacyLabels := GetLegacyLabels(component)

10
vendor/github.com/openshift/api/security/v1/consts.go generated vendored Normal file
View File

@ -0,0 +1,10 @@
package v1
const (
UIDRangeAnnotation = "openshift.io/sa.scc.uid-range"
// SupplementalGroupsAnnotation contains a comma delimited list of allocated supplemental groups
// for the namespace. Groups are in the form of a Block which supports {start}/{length} or {start}-{end}
SupplementalGroupsAnnotation = "openshift.io/sa.scc.supplemental-groups"
MCSAnnotation = "openshift.io/sa.scc.mcs"
ValidatedSCCAnnotation = "openshift.io/scc"
)

8
vendor/github.com/openshift/api/security/v1/doc.go generated vendored Normal file
View File

@ -0,0 +1,8 @@
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/openshift/origin/pkg/security/apis/security
// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true
// +groupName=security.openshift.io
// Package v1 is the v1 version of the API.
package v1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,349 @@
// This file was autogenerated by go-to-protobuf. Do not edit it manually!
syntax = 'proto2';
package github.com.openshift.api.security.v1;
import "k8s.io/api/core/v1/generated.proto";
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
// Package-wide variables from generator "generated".
option go_package = "v1";
// AllowedFlexVolume represents a single Flexvolume that is allowed to be used.
message AllowedFlexVolume {
// Driver is the name of the Flexvolume driver.
optional string driver = 1;
}
// FSGroupStrategyOptions defines the strategy type and options used to create the strategy.
message FSGroupStrategyOptions {
// Type is the strategy that will dictate what FSGroup is used in the SecurityContext.
optional string type = 1;
// Ranges are the allowed ranges of fs groups. If you would like to force a single
// fs group then supply a single range with the same start and end.
repeated IDRange ranges = 2;
}
// IDRange provides a min/max of an allowed range of IDs.
// TODO: this could be reused for UIDs.
message IDRange {
// Min is the start of the range, inclusive.
optional int64 min = 1;
// Max is the end of the range, inclusive.
optional int64 max = 2;
}
// PodSecurityPolicyReview checks which service accounts (not users, since that would be cluster-wide) can create the `PodTemplateSpec` in question.
message PodSecurityPolicyReview {
// spec is the PodSecurityPolicy to check.
optional PodSecurityPolicyReviewSpec spec = 1;
// status represents the current information/status for the PodSecurityPolicyReview.
optional PodSecurityPolicyReviewStatus status = 2;
}
// PodSecurityPolicyReviewSpec defines specification for PodSecurityPolicyReview
message PodSecurityPolicyReviewSpec {
// template is the PodTemplateSpec to check. The template.spec.serviceAccountName field is used
// if serviceAccountNames is empty, unless the template.spec.serviceAccountName is empty,
// in which case "default" is used.
// If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.
optional k8s.io.api.core.v1.PodTemplateSpec template = 1;
// serviceAccountNames is an optional set of ServiceAccounts to run the check with.
// If serviceAccountNames is empty, the template.spec.serviceAccountName is used,
// unless it's empty, in which case "default" is used instead.
// If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.
repeated string serviceAccountNames = 2;
}
// PodSecurityPolicyReviewStatus represents the status of PodSecurityPolicyReview.
message PodSecurityPolicyReviewStatus {
// allowedServiceAccounts returns the list of service accounts in *this* namespace that have the power to create the PodTemplateSpec.
repeated ServiceAccountPodSecurityPolicyReviewStatus allowedServiceAccounts = 1;
}
// PodSecurityPolicySelfSubjectReview checks whether this user/SA tuple can create the PodTemplateSpec
message PodSecurityPolicySelfSubjectReview {
// spec defines specification the PodSecurityPolicySelfSubjectReview.
optional PodSecurityPolicySelfSubjectReviewSpec spec = 1;
// status represents the current information/status for the PodSecurityPolicySelfSubjectReview.
optional PodSecurityPolicySubjectReviewStatus status = 2;
}
// PodSecurityPolicySelfSubjectReviewSpec contains specification for PodSecurityPolicySelfSubjectReview.
message PodSecurityPolicySelfSubjectReviewSpec {
// template is the PodTemplateSpec to check.
optional k8s.io.api.core.v1.PodTemplateSpec template = 1;
}
// PodSecurityPolicySubjectReview checks whether a particular user/SA tuple can create the PodTemplateSpec.
message PodSecurityPolicySubjectReview {
// spec defines specification for the PodSecurityPolicySubjectReview.
optional PodSecurityPolicySubjectReviewSpec spec = 1;
// status represents the current information/status for the PodSecurityPolicySubjectReview.
optional PodSecurityPolicySubjectReviewStatus status = 2;
}
// PodSecurityPolicySubjectReviewSpec defines specification for PodSecurityPolicySubjectReview
message PodSecurityPolicySubjectReviewSpec {
// template is the PodTemplateSpec to check. If template.spec.serviceAccountName is empty it will not be defaulted.
// If its non-empty, it will be checked.
optional k8s.io.api.core.v1.PodTemplateSpec template = 1;
// user is the user you're testing for.
// If you specify "user" but not "group", then is it interpreted as "What if user were not a member of any groups.
// If user and groups are empty, then the check is performed using *only* the serviceAccountName in the template.
optional string user = 2;
// groups is the groups you're testing for.
repeated string groups = 3;
}
// PodSecurityPolicySubjectReviewStatus contains information/status for PodSecurityPolicySubjectReview.
message PodSecurityPolicySubjectReviewStatus {
// allowedBy is a reference to the rule that allows the PodTemplateSpec.
// A rule can be a SecurityContextConstraint or a PodSecurityPolicy
// A `nil`, indicates that it was denied.
optional k8s.io.api.core.v1.ObjectReference allowedBy = 1;
// A machine-readable description of why this operation is in the
// "Failure" status. If this value is empty there
// is no information available.
optional string reason = 2;
// template is the PodTemplateSpec after the defaulting is applied.
optional k8s.io.api.core.v1.PodTemplateSpec template = 3;
}
// RangeAllocation is used so we can easily expose a RangeAllocation typed for security group
message RangeAllocation {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// range is a string representing a unique label for a range of uids, "1000000000-2000000000/10000".
optional string range = 2;
// data is a byte array representing the serialized state of a range allocation. It is a bitmap
// with each bit set to one to represent a range is taken.
optional bytes data = 3;
}
// RangeAllocationList is a list of RangeAllocations objects
message RangeAllocationList {
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// List of RangeAllocations.
repeated RangeAllocation items = 2;
}
// RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.
message RunAsUserStrategyOptions {
// Type is the strategy that will dictate what RunAsUser is used in the SecurityContext.
optional string type = 1;
// UID is the user id that containers must run as. Required for the MustRunAs strategy if not using
// namespace/service account allocated uids.
optional int64 uid = 2;
// UIDRangeMin defines the min value for a strategy that allocates by range.
optional int64 uidRangeMin = 3;
// UIDRangeMax defines the max value for a strategy that allocates by range.
optional int64 uidRangeMax = 4;
}
// SELinuxContextStrategyOptions defines the strategy type and any options used to create the strategy.
message SELinuxContextStrategyOptions {
// Type is the strategy that will dictate what SELinux context is used in the SecurityContext.
optional string type = 1;
// seLinuxOptions required to run as; required for MustRunAs
optional k8s.io.api.core.v1.SELinuxOptions seLinuxOptions = 2;
}
// SecurityContextConstraints governs the ability to make requests that affect the SecurityContext
// that will be applied to a container.
// For historical reasons SCC was exposed under the core Kubernetes API group.
// That exposure is deprecated and will be removed in a future release - users
// should instead use the security.openshift.io group to manage
// SecurityContextConstraints.
// +kubebuilder:singular=securitycontextconstraint
message SecurityContextConstraints {
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// Priority influences the sort order of SCCs when evaluating which SCCs to try first for
// a given pod request based on access in the Users and Groups fields. The higher the int, the
// higher priority. An unset value is considered a 0 priority. If scores
// for multiple SCCs are equal they will be sorted from most restrictive to
// least restrictive. If both priorities and restrictions are equal the
// SCCs will be sorted by name.
// +nullable
optional int32 priority = 2;
// AllowPrivilegedContainer determines if a container can request to be run as privileged.
optional bool allowPrivilegedContainer = 3;
// DefaultAddCapabilities is the default set of capabilities that will be added to the container
// unless the pod spec specifically drops the capability. You may not list a capabiility in both
// DefaultAddCapabilities and RequiredDropCapabilities.
// +nullable
repeated string defaultAddCapabilities = 4;
// RequiredDropCapabilities are the capabilities that will be dropped from the container. These
// are required to be dropped and cannot be added.
// +nullable
repeated string requiredDropCapabilities = 5;
// AllowedCapabilities is a list of capabilities that can be requested to add to the container.
// Capabilities in this field maybe added at the pod author's discretion.
// You must not list a capability in both AllowedCapabilities and RequiredDropCapabilities.
// To allow all capabilities you may use '*'.
// +nullable
repeated string allowedCapabilities = 6;
// AllowHostDirVolumePlugin determines if the policy allow containers to use the HostDir volume plugin
// +k8s:conversion-gen=false
optional bool allowHostDirVolumePlugin = 7;
// Volumes is a white list of allowed volume plugins. FSType corresponds directly with the field names
// of a VolumeSource (azureFile, configMap, emptyDir). To allow all volumes you may use "*".
// To allow no volumes, set to ["none"].
// +nullable
repeated string volumes = 8;
// AllowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all
// Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes
// is allowed in the "Volumes" field.
// +optional
// +nullable
repeated AllowedFlexVolume allowedFlexVolumes = 21;
// AllowHostNetwork determines if the policy allows the use of HostNetwork in the pod spec.
optional bool allowHostNetwork = 9;
// AllowHostPorts determines if the policy allows host ports in the containers.
optional bool allowHostPorts = 10;
// AllowHostPID determines if the policy allows host pid in the containers.
optional bool allowHostPID = 11;
// AllowHostIPC determines if the policy allows host ipc in the containers.
optional bool allowHostIPC = 12;
// DefaultAllowPrivilegeEscalation controls the default setting for whether a
// process can gain more privileges than its parent process.
// +optional
// +nullable
optional bool defaultAllowPrivilegeEscalation = 22;
// AllowPrivilegeEscalation determines if a pod can request to allow
// privilege escalation. If unspecified, defaults to true.
// +optional
// +nullable
optional bool allowPrivilegeEscalation = 23;
// SELinuxContext is the strategy that will dictate what labels will be set in the SecurityContext.
// +nullable
optional SELinuxContextStrategyOptions seLinuxContext = 13;
// RunAsUser is the strategy that will dictate what RunAsUser is used in the SecurityContext.
// +nullable
optional RunAsUserStrategyOptions runAsUser = 14;
// SupplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.
// +nullable
optional SupplementalGroupsStrategyOptions supplementalGroups = 15;
// FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.
// +nullable
optional FSGroupStrategyOptions fsGroup = 16;
// ReadOnlyRootFilesystem when set to true will force containers to run with a read only root file
// system. If the container specifically requests to run with a non-read only root file system
// the SCC should deny the pod.
// If set to false the container may run with a read only root file system if it wishes but it
// will not be forced to.
optional bool readOnlyRootFilesystem = 17;
// The users who have permissions to use this security context constraints
// +optional
// +nullable
repeated string users = 18;
// The groups that have permission to use this security context constraints
// +optional
// +nullable
repeated string groups = 19;
// SeccompProfiles lists the allowed profiles that may be set for the pod or
// container's seccomp annotations. An unset (nil) or empty value means that no profiles may
// be specifid by the pod or container. The wildcard '*' may be used to allow all profiles. When
// used to generate a value for a pod the first non-wildcard profile will be used as
// the default.
// +nullable
repeated string seccompProfiles = 20;
// AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
// Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
//
// Examples:
// e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
// e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
// +optional
// +nullable
repeated string allowedUnsafeSysctls = 24;
// ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
//
// Examples:
// e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
// e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
// +optional
// +nullable
repeated string forbiddenSysctls = 25;
}
// SecurityContextConstraintsList is a list of SecurityContextConstraints objects
message SecurityContextConstraintsList {
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// List of security context constraints.
repeated SecurityContextConstraints items = 2;
}
// ServiceAccountPodSecurityPolicyReviewStatus represents ServiceAccount name and related review status
message ServiceAccountPodSecurityPolicyReviewStatus {
optional PodSecurityPolicySubjectReviewStatus podSecurityPolicySubjectReviewStatus = 1;
// name contains the allowed and the denied ServiceAccount name
optional string name = 2;
}
// SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.
message SupplementalGroupsStrategyOptions {
// Type is the strategy that will dictate what supplemental groups is used in the SecurityContext.
optional string type = 1;
// Ranges are the allowed ranges of supplemental groups. If you would like to force a single
// supplemental group then supply a single range with the same start and end.
repeated IDRange ranges = 2;
}

25
vendor/github.com/openshift/api/security/v1/legacy.go generated vendored Normal file
View File

@ -0,0 +1,25 @@
package v1
import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var (
legacyGroupVersion = schema.GroupVersion{Group: "", Version: "v1"}
legacySchemeBuilder = runtime.NewSchemeBuilder(addLegacyKnownTypes, corev1.AddToScheme)
DeprecatedInstallWithoutGroup = legacySchemeBuilder.AddToScheme
)
func addLegacyKnownTypes(scheme *runtime.Scheme) error {
types := []runtime.Object{
&SecurityContextConstraints{},
&SecurityContextConstraintsList{},
&PodSecurityPolicySubjectReview{},
&PodSecurityPolicySelfSubjectReview{},
&PodSecurityPolicyReview{},
}
scheme.AddKnownTypes(legacyGroupVersion, types...)
return nil
}

View File

@ -0,0 +1,44 @@
package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var (
GroupName = "security.openshift.io"
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, corev1.AddToScheme)
// Install is a function which adds this version to a scheme
Install = schemeBuilder.AddToScheme
// SchemeGroupVersion generated code relies on this name
// Deprecated
SchemeGroupVersion = GroupVersion
// AddToScheme exists solely to keep the old generators creating valid code
// DEPRECATED
AddToScheme = schemeBuilder.AddToScheme
)
// Resource generated code relies on this being here, but it logically belongs to the group
// DEPRECATED
func Resource(resource string) schema.GroupResource {
return schema.GroupResource{Group: GroupName, Resource: resource}
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&SecurityContextConstraints{},
&SecurityContextConstraintsList{},
&PodSecurityPolicySubjectReview{},
&PodSecurityPolicySelfSubjectReview{},
&PodSecurityPolicyReview{},
&RangeAllocation{},
&RangeAllocationList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}

434
vendor/github.com/openshift/api/security/v1/types.go generated vendored Normal file
View File

@ -0,0 +1,434 @@
package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// AllowAllCapabilities can be used as a value for the
// SecurityContextConstraints.AllowAllCapabilities field and means that any
// capabilities are allowed to be requested.
var AllowAllCapabilities corev1.Capability = "*"
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// SecurityContextConstraints governs the ability to make requests that affect the SecurityContext
// that will be applied to a container.
// For historical reasons SCC was exposed under the core Kubernetes API group.
// That exposure is deprecated and will be removed in a future release - users
// should instead use the security.openshift.io group to manage
// SecurityContextConstraints.
// +kubebuilder:singular=securitycontextconstraint
type SecurityContextConstraints struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Priority influences the sort order of SCCs when evaluating which SCCs to try first for
// a given pod request based on access in the Users and Groups fields. The higher the int, the
// higher priority. An unset value is considered a 0 priority. If scores
// for multiple SCCs are equal they will be sorted from most restrictive to
// least restrictive. If both priorities and restrictions are equal the
// SCCs will be sorted by name.
// +nullable
Priority *int32 `json:"priority" protobuf:"varint,2,opt,name=priority"`
// AllowPrivilegedContainer determines if a container can request to be run as privileged.
AllowPrivilegedContainer bool `json:"allowPrivilegedContainer" protobuf:"varint,3,opt,name=allowPrivilegedContainer"`
// DefaultAddCapabilities is the default set of capabilities that will be added to the container
// unless the pod spec specifically drops the capability. You may not list a capabiility in both
// DefaultAddCapabilities and RequiredDropCapabilities.
// +nullable
DefaultAddCapabilities []corev1.Capability `json:"defaultAddCapabilities" protobuf:"bytes,4,rep,name=defaultAddCapabilities,casttype=Capability"`
// RequiredDropCapabilities are the capabilities that will be dropped from the container. These
// are required to be dropped and cannot be added.
// +nullable
RequiredDropCapabilities []corev1.Capability `json:"requiredDropCapabilities" protobuf:"bytes,5,rep,name=requiredDropCapabilities,casttype=Capability"`
// AllowedCapabilities is a list of capabilities that can be requested to add to the container.
// Capabilities in this field maybe added at the pod author's discretion.
// You must not list a capability in both AllowedCapabilities and RequiredDropCapabilities.
// To allow all capabilities you may use '*'.
// +nullable
AllowedCapabilities []corev1.Capability `json:"allowedCapabilities" protobuf:"bytes,6,rep,name=allowedCapabilities,casttype=Capability"`
// AllowHostDirVolumePlugin determines if the policy allow containers to use the HostDir volume plugin
// +k8s:conversion-gen=false
AllowHostDirVolumePlugin bool `json:"allowHostDirVolumePlugin" protobuf:"varint,7,opt,name=allowHostDirVolumePlugin"`
// Volumes is a white list of allowed volume plugins. FSType corresponds directly with the field names
// of a VolumeSource (azureFile, configMap, emptyDir). To allow all volumes you may use "*".
// To allow no volumes, set to ["none"].
// +nullable
Volumes []FSType `json:"volumes" protobuf:"bytes,8,rep,name=volumes,casttype=FSType"`
// AllowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all
// Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes
// is allowed in the "Volumes" field.
// +optional
// +nullable
AllowedFlexVolumes []AllowedFlexVolume `json:"allowedFlexVolumes,omitempty" protobuf:"bytes,21,rep,name=allowedFlexVolumes"`
// AllowHostNetwork determines if the policy allows the use of HostNetwork in the pod spec.
AllowHostNetwork bool `json:"allowHostNetwork" protobuf:"varint,9,opt,name=allowHostNetwork"`
// AllowHostPorts determines if the policy allows host ports in the containers.
AllowHostPorts bool `json:"allowHostPorts" protobuf:"varint,10,opt,name=allowHostPorts"`
// AllowHostPID determines if the policy allows host pid in the containers.
AllowHostPID bool `json:"allowHostPID" protobuf:"varint,11,opt,name=allowHostPID"`
// AllowHostIPC determines if the policy allows host ipc in the containers.
AllowHostIPC bool `json:"allowHostIPC" protobuf:"varint,12,opt,name=allowHostIPC"`
// DefaultAllowPrivilegeEscalation controls the default setting for whether a
// process can gain more privileges than its parent process.
// +optional
// +nullable
DefaultAllowPrivilegeEscalation *bool `json:"defaultAllowPrivilegeEscalation,omitempty" protobuf:"varint,22,rep,name=defaultAllowPrivilegeEscalation"`
// AllowPrivilegeEscalation determines if a pod can request to allow
// privilege escalation. If unspecified, defaults to true.
// +optional
// +nullable
AllowPrivilegeEscalation *bool `json:"allowPrivilegeEscalation,omitempty" protobuf:"varint,23,rep,name=allowPrivilegeEscalation"`
// SELinuxContext is the strategy that will dictate what labels will be set in the SecurityContext.
// +nullable
SELinuxContext SELinuxContextStrategyOptions `json:"seLinuxContext,omitempty" protobuf:"bytes,13,opt,name=seLinuxContext"`
// RunAsUser is the strategy that will dictate what RunAsUser is used in the SecurityContext.
// +nullable
RunAsUser RunAsUserStrategyOptions `json:"runAsUser,omitempty" protobuf:"bytes,14,opt,name=runAsUser"`
// SupplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.
// +nullable
SupplementalGroups SupplementalGroupsStrategyOptions `json:"supplementalGroups,omitempty" protobuf:"bytes,15,opt,name=supplementalGroups"`
// FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.
// +nullable
FSGroup FSGroupStrategyOptions `json:"fsGroup,omitempty" protobuf:"bytes,16,opt,name=fsGroup"`
// ReadOnlyRootFilesystem when set to true will force containers to run with a read only root file
// system. If the container specifically requests to run with a non-read only root file system
// the SCC should deny the pod.
// If set to false the container may run with a read only root file system if it wishes but it
// will not be forced to.
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem" protobuf:"varint,17,opt,name=readOnlyRootFilesystem"`
// The users who have permissions to use this security context constraints
// +optional
// +nullable
Users []string `json:"users" protobuf:"bytes,18,rep,name=users"`
// The groups that have permission to use this security context constraints
// +optional
// +nullable
Groups []string `json:"groups" protobuf:"bytes,19,rep,name=groups"`
// SeccompProfiles lists the allowed profiles that may be set for the pod or
// container's seccomp annotations. An unset (nil) or empty value means that no profiles may
// be specifid by the pod or container. The wildcard '*' may be used to allow all profiles. When
// used to generate a value for a pod the first non-wildcard profile will be used as
// the default.
// +nullable
SeccompProfiles []string `json:"seccompProfiles,omitempty" protobuf:"bytes,20,opt,name=seccompProfiles"`
// AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
// Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
//
// Examples:
// e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
// e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
// +optional
// +nullable
AllowedUnsafeSysctls []string `json:"allowedUnsafeSysctls,omitempty" protobuf:"bytes,24,rep,name=allowedUnsafeSysctls"`
// ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
//
// Examples:
// e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
// e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
// +optional
// +nullable
ForbiddenSysctls []string `json:"forbiddenSysctls,omitempty" protobuf:"bytes,25,rep,name=forbiddenSysctls"`
}
// FS Type gives strong typing to different file systems that are used by volumes.
type FSType string
var (
FSTypeAzureFile FSType = "azureFile"
FSTypeAzureDisk FSType = "azureDisk"
FSTypeFlocker FSType = "flocker"
FSTypeFlexVolume FSType = "flexVolume"
FSTypeHostPath FSType = "hostPath"
FSTypeEmptyDir FSType = "emptyDir"
FSTypeGCEPersistentDisk FSType = "gcePersistentDisk"
FSTypeAWSElasticBlockStore FSType = "awsElasticBlockStore"
FSTypeGitRepo FSType = "gitRepo"
FSTypeSecret FSType = "secret"
FSTypeNFS FSType = "nfs"
FSTypeISCSI FSType = "iscsi"
FSTypeGlusterfs FSType = "glusterfs"
FSTypePersistentVolumeClaim FSType = "persistentVolumeClaim"
FSTypeRBD FSType = "rbd"
FSTypeCinder FSType = "cinder"
FSTypeCephFS FSType = "cephFS"
FSTypeDownwardAPI FSType = "downwardAPI"
FSTypeFC FSType = "fc"
FSTypeConfigMap FSType = "configMap"
FSTypeVsphereVolume FSType = "vsphere"
FSTypeQuobyte FSType = "quobyte"
FSTypePhotonPersistentDisk FSType = "photonPersistentDisk"
FSProjected FSType = "projected"
FSPortworxVolume FSType = "portworxVolume"
FSScaleIO FSType = "scaleIO"
FSStorageOS FSType = "storageOS"
FSTypeCSI FSType = "csi"
FSTypeAll FSType = "*"
FSTypeNone FSType = "none"
)
// AllowedFlexVolume represents a single Flexvolume that is allowed to be used.
type AllowedFlexVolume struct {
// Driver is the name of the Flexvolume driver.
Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"`
}
// SELinuxContextStrategyOptions defines the strategy type and any options used to create the strategy.
type SELinuxContextStrategyOptions struct {
// Type is the strategy that will dictate what SELinux context is used in the SecurityContext.
Type SELinuxContextStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=SELinuxContextStrategyType"`
// seLinuxOptions required to run as; required for MustRunAs
SELinuxOptions *corev1.SELinuxOptions `json:"seLinuxOptions,omitempty" protobuf:"bytes,2,opt,name=seLinuxOptions"`
}
// RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.
type RunAsUserStrategyOptions struct {
// Type is the strategy that will dictate what RunAsUser is used in the SecurityContext.
Type RunAsUserStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=RunAsUserStrategyType"`
// UID is the user id that containers must run as. Required for the MustRunAs strategy if not using
// namespace/service account allocated uids.
UID *int64 `json:"uid,omitempty" protobuf:"varint,2,opt,name=uid"`
// UIDRangeMin defines the min value for a strategy that allocates by range.
UIDRangeMin *int64 `json:"uidRangeMin,omitempty" protobuf:"varint,3,opt,name=uidRangeMin"`
// UIDRangeMax defines the max value for a strategy that allocates by range.
UIDRangeMax *int64 `json:"uidRangeMax,omitempty" protobuf:"varint,4,opt,name=uidRangeMax"`
}
// FSGroupStrategyOptions defines the strategy type and options used to create the strategy.
type FSGroupStrategyOptions struct {
// Type is the strategy that will dictate what FSGroup is used in the SecurityContext.
Type FSGroupStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=FSGroupStrategyType"`
// Ranges are the allowed ranges of fs groups. If you would like to force a single
// fs group then supply a single range with the same start and end.
Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
}
// SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.
type SupplementalGroupsStrategyOptions struct {
// Type is the strategy that will dictate what supplemental groups is used in the SecurityContext.
Type SupplementalGroupsStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=SupplementalGroupsStrategyType"`
// Ranges are the allowed ranges of supplemental groups. If you would like to force a single
// supplemental group then supply a single range with the same start and end.
Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
}
// IDRange provides a min/max of an allowed range of IDs.
// TODO: this could be reused for UIDs.
type IDRange struct {
// Min is the start of the range, inclusive.
Min int64 `json:"min,omitempty" protobuf:"varint,1,opt,name=min"`
// Max is the end of the range, inclusive.
Max int64 `json:"max,omitempty" protobuf:"varint,2,opt,name=max"`
}
// SELinuxContextStrategyType denotes strategy types for generating SELinux options for a
// SecurityContext
type SELinuxContextStrategyType string
// RunAsUserStrategyType denotes strategy types for generating RunAsUser values for a
// SecurityContext
type RunAsUserStrategyType string
// SupplementalGroupsStrategyType denotes strategy types for determining valid supplemental
// groups for a SecurityContext.
type SupplementalGroupsStrategyType string
// FSGroupStrategyType denotes strategy types for generating FSGroup values for a
// SecurityContext
type FSGroupStrategyType string
const (
// container must have SELinux labels of X applied.
SELinuxStrategyMustRunAs SELinuxContextStrategyType = "MustRunAs"
// container may make requests for any SELinux context labels.
SELinuxStrategyRunAsAny SELinuxContextStrategyType = "RunAsAny"
// container must run as a particular uid.
RunAsUserStrategyMustRunAs RunAsUserStrategyType = "MustRunAs"
// container must run as a particular uid.
RunAsUserStrategyMustRunAsRange RunAsUserStrategyType = "MustRunAsRange"
// container must run as a non-root uid
RunAsUserStrategyMustRunAsNonRoot RunAsUserStrategyType = "MustRunAsNonRoot"
// container may make requests for any uid.
RunAsUserStrategyRunAsAny RunAsUserStrategyType = "RunAsAny"
// container must have FSGroup of X applied.
FSGroupStrategyMustRunAs FSGroupStrategyType = "MustRunAs"
// container may make requests for any FSGroup labels.
FSGroupStrategyRunAsAny FSGroupStrategyType = "RunAsAny"
// container must run as a particular gid.
SupplementalGroupsStrategyMustRunAs SupplementalGroupsStrategyType = "MustRunAs"
// container may make requests for any gid.
SupplementalGroupsStrategyRunAsAny SupplementalGroupsStrategyType = "RunAsAny"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// SecurityContextConstraintsList is a list of SecurityContextConstraints objects
type SecurityContextConstraintsList struct {
metav1.TypeMeta `json:",inline"`
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of security context constraints.
Items []SecurityContextConstraints `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +genclient
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PodSecurityPolicySubjectReview checks whether a particular user/SA tuple can create the PodTemplateSpec.
type PodSecurityPolicySubjectReview struct {
metav1.TypeMeta `json:",inline"`
// spec defines specification for the PodSecurityPolicySubjectReview.
Spec PodSecurityPolicySubjectReviewSpec `json:"spec" protobuf:"bytes,1,opt,name=spec"`
// status represents the current information/status for the PodSecurityPolicySubjectReview.
Status PodSecurityPolicySubjectReviewStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
}
// PodSecurityPolicySubjectReviewSpec defines specification for PodSecurityPolicySubjectReview
type PodSecurityPolicySubjectReviewSpec struct {
// template is the PodTemplateSpec to check. If template.spec.serviceAccountName is empty it will not be defaulted.
// If its non-empty, it will be checked.
Template corev1.PodTemplateSpec `json:"template" protobuf:"bytes,1,opt,name=template"`
// user is the user you're testing for.
// If you specify "user" but not "group", then is it interpreted as "What if user were not a member of any groups.
// If user and groups are empty, then the check is performed using *only* the serviceAccountName in the template.
User string `json:"user,omitempty" protobuf:"bytes,2,opt,name=user"`
// groups is the groups you're testing for.
Groups []string `json:"groups,omitempty" protobuf:"bytes,3,rep,name=groups"`
}
// PodSecurityPolicySubjectReviewStatus contains information/status for PodSecurityPolicySubjectReview.
type PodSecurityPolicySubjectReviewStatus struct {
// allowedBy is a reference to the rule that allows the PodTemplateSpec.
// A rule can be a SecurityContextConstraint or a PodSecurityPolicy
// A `nil`, indicates that it was denied.
AllowedBy *corev1.ObjectReference `json:"allowedBy,omitempty" protobuf:"bytes,1,opt,name=allowedBy"`
// A machine-readable description of why this operation is in the
// "Failure" status. If this value is empty there
// is no information available.
Reason string `json:"reason,omitempty" protobuf:"bytes,2,opt,name=reason"`
// template is the PodTemplateSpec after the defaulting is applied.
Template corev1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
}
// +genclient
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PodSecurityPolicySelfSubjectReview checks whether this user/SA tuple can create the PodTemplateSpec
type PodSecurityPolicySelfSubjectReview struct {
metav1.TypeMeta `json:",inline"`
// spec defines specification the PodSecurityPolicySelfSubjectReview.
Spec PodSecurityPolicySelfSubjectReviewSpec `json:"spec" protobuf:"bytes,1,opt,name=spec"`
// status represents the current information/status for the PodSecurityPolicySelfSubjectReview.
Status PodSecurityPolicySubjectReviewStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
}
// PodSecurityPolicySelfSubjectReviewSpec contains specification for PodSecurityPolicySelfSubjectReview.
type PodSecurityPolicySelfSubjectReviewSpec struct {
// template is the PodTemplateSpec to check.
Template corev1.PodTemplateSpec `json:"template" protobuf:"bytes,1,opt,name=template"`
}
// +genclient
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PodSecurityPolicyReview checks which service accounts (not users, since that would be cluster-wide) can create the `PodTemplateSpec` in question.
type PodSecurityPolicyReview struct {
metav1.TypeMeta `json:",inline"`
// spec is the PodSecurityPolicy to check.
Spec PodSecurityPolicyReviewSpec `json:"spec" protobuf:"bytes,1,opt,name=spec"`
// status represents the current information/status for the PodSecurityPolicyReview.
Status PodSecurityPolicyReviewStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
}
// PodSecurityPolicyReviewSpec defines specification for PodSecurityPolicyReview
type PodSecurityPolicyReviewSpec struct {
// template is the PodTemplateSpec to check. The template.spec.serviceAccountName field is used
// if serviceAccountNames is empty, unless the template.spec.serviceAccountName is empty,
// in which case "default" is used.
// If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.
Template corev1.PodTemplateSpec `json:"template" protobuf:"bytes,1,opt,name=template"`
// serviceAccountNames is an optional set of ServiceAccounts to run the check with.
// If serviceAccountNames is empty, the template.spec.serviceAccountName is used,
// unless it's empty, in which case "default" is used instead.
// If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.
ServiceAccountNames []string `json:"serviceAccountNames,omitempty" protobuf:"bytes,2,rep,name=serviceAccountNames"` // TODO: find a way to express 'all service accounts'
}
// PodSecurityPolicyReviewStatus represents the status of PodSecurityPolicyReview.
type PodSecurityPolicyReviewStatus struct {
// allowedServiceAccounts returns the list of service accounts in *this* namespace that have the power to create the PodTemplateSpec.
AllowedServiceAccounts []ServiceAccountPodSecurityPolicyReviewStatus `json:"allowedServiceAccounts" protobuf:"bytes,1,rep,name=allowedServiceAccounts"`
}
// ServiceAccountPodSecurityPolicyReviewStatus represents ServiceAccount name and related review status
type ServiceAccountPodSecurityPolicyReviewStatus struct {
PodSecurityPolicySubjectReviewStatus `json:",inline" protobuf:"bytes,1,opt,name=podSecurityPolicySubjectReviewStatus"`
// name contains the allowed and the denied ServiceAccount name
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RangeAllocation is used so we can easily expose a RangeAllocation typed for security group
type RangeAllocation struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// range is a string representing a unique label for a range of uids, "1000000000-2000000000/10000".
Range string `json:"range" protobuf:"bytes,2,opt,name=range"`
// data is a byte array representing the serialized state of a range allocation. It is a bitmap
// with each bit set to one to represent a range is taken.
Data []byte `json:"data" protobuf:"bytes,3,opt,name=data"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RangeAllocationList is a list of RangeAllocations objects
type RangeAllocationList struct {
metav1.TypeMeta `json:",inline"`
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of RangeAllocations.
Items []RangeAllocation `json:"items" protobuf:"bytes,2,rep,name=items"`
}

View File

@ -0,0 +1,532 @@
// +build !ignore_autogenerated
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1
import (
corev1 "k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AllowedFlexVolume) DeepCopyInto(out *AllowedFlexVolume) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllowedFlexVolume.
func (in *AllowedFlexVolume) DeepCopy() *AllowedFlexVolume {
if in == nil {
return nil
}
out := new(AllowedFlexVolume)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FSGroupStrategyOptions) DeepCopyInto(out *FSGroupStrategyOptions) {
*out = *in
if in.Ranges != nil {
in, out := &in.Ranges, &out.Ranges
*out = make([]IDRange, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FSGroupStrategyOptions.
func (in *FSGroupStrategyOptions) DeepCopy() *FSGroupStrategyOptions {
if in == nil {
return nil
}
out := new(FSGroupStrategyOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IDRange) DeepCopyInto(out *IDRange) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IDRange.
func (in *IDRange) DeepCopy() *IDRange {
if in == nil {
return nil
}
out := new(IDRange)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicyReview) DeepCopyInto(out *PodSecurityPolicyReview) {
*out = *in
out.TypeMeta = in.TypeMeta
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicyReview.
func (in *PodSecurityPolicyReview) DeepCopy() *PodSecurityPolicyReview {
if in == nil {
return nil
}
out := new(PodSecurityPolicyReview)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PodSecurityPolicyReview) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicyReviewSpec) DeepCopyInto(out *PodSecurityPolicyReviewSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
if in.ServiceAccountNames != nil {
in, out := &in.ServiceAccountNames, &out.ServiceAccountNames
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicyReviewSpec.
func (in *PodSecurityPolicyReviewSpec) DeepCopy() *PodSecurityPolicyReviewSpec {
if in == nil {
return nil
}
out := new(PodSecurityPolicyReviewSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicyReviewStatus) DeepCopyInto(out *PodSecurityPolicyReviewStatus) {
*out = *in
if in.AllowedServiceAccounts != nil {
in, out := &in.AllowedServiceAccounts, &out.AllowedServiceAccounts
*out = make([]ServiceAccountPodSecurityPolicyReviewStatus, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicyReviewStatus.
func (in *PodSecurityPolicyReviewStatus) DeepCopy() *PodSecurityPolicyReviewStatus {
if in == nil {
return nil
}
out := new(PodSecurityPolicyReviewStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicySelfSubjectReview) DeepCopyInto(out *PodSecurityPolicySelfSubjectReview) {
*out = *in
out.TypeMeta = in.TypeMeta
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicySelfSubjectReview.
func (in *PodSecurityPolicySelfSubjectReview) DeepCopy() *PodSecurityPolicySelfSubjectReview {
if in == nil {
return nil
}
out := new(PodSecurityPolicySelfSubjectReview)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PodSecurityPolicySelfSubjectReview) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicySelfSubjectReviewSpec) DeepCopyInto(out *PodSecurityPolicySelfSubjectReviewSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicySelfSubjectReviewSpec.
func (in *PodSecurityPolicySelfSubjectReviewSpec) DeepCopy() *PodSecurityPolicySelfSubjectReviewSpec {
if in == nil {
return nil
}
out := new(PodSecurityPolicySelfSubjectReviewSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicySubjectReview) DeepCopyInto(out *PodSecurityPolicySubjectReview) {
*out = *in
out.TypeMeta = in.TypeMeta
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicySubjectReview.
func (in *PodSecurityPolicySubjectReview) DeepCopy() *PodSecurityPolicySubjectReview {
if in == nil {
return nil
}
out := new(PodSecurityPolicySubjectReview)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PodSecurityPolicySubjectReview) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicySubjectReviewSpec) DeepCopyInto(out *PodSecurityPolicySubjectReviewSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
if in.Groups != nil {
in, out := &in.Groups, &out.Groups
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicySubjectReviewSpec.
func (in *PodSecurityPolicySubjectReviewSpec) DeepCopy() *PodSecurityPolicySubjectReviewSpec {
if in == nil {
return nil
}
out := new(PodSecurityPolicySubjectReviewSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSecurityPolicySubjectReviewStatus) DeepCopyInto(out *PodSecurityPolicySubjectReviewStatus) {
*out = *in
if in.AllowedBy != nil {
in, out := &in.AllowedBy, &out.AllowedBy
*out = new(corev1.ObjectReference)
**out = **in
}
in.Template.DeepCopyInto(&out.Template)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSecurityPolicySubjectReviewStatus.
func (in *PodSecurityPolicySubjectReviewStatus) DeepCopy() *PodSecurityPolicySubjectReviewStatus {
if in == nil {
return nil
}
out := new(PodSecurityPolicySubjectReviewStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RangeAllocation) DeepCopyInto(out *RangeAllocation) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.Data != nil {
in, out := &in.Data, &out.Data
*out = make([]byte, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RangeAllocation.
func (in *RangeAllocation) DeepCopy() *RangeAllocation {
if in == nil {
return nil
}
out := new(RangeAllocation)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RangeAllocation) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RangeAllocationList) DeepCopyInto(out *RangeAllocationList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]RangeAllocation, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RangeAllocationList.
func (in *RangeAllocationList) DeepCopy() *RangeAllocationList {
if in == nil {
return nil
}
out := new(RangeAllocationList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RangeAllocationList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RunAsUserStrategyOptions) DeepCopyInto(out *RunAsUserStrategyOptions) {
*out = *in
if in.UID != nil {
in, out := &in.UID, &out.UID
*out = new(int64)
**out = **in
}
if in.UIDRangeMin != nil {
in, out := &in.UIDRangeMin, &out.UIDRangeMin
*out = new(int64)
**out = **in
}
if in.UIDRangeMax != nil {
in, out := &in.UIDRangeMax, &out.UIDRangeMax
*out = new(int64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunAsUserStrategyOptions.
func (in *RunAsUserStrategyOptions) DeepCopy() *RunAsUserStrategyOptions {
if in == nil {
return nil
}
out := new(RunAsUserStrategyOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SELinuxContextStrategyOptions) DeepCopyInto(out *SELinuxContextStrategyOptions) {
*out = *in
if in.SELinuxOptions != nil {
in, out := &in.SELinuxOptions, &out.SELinuxOptions
*out = new(corev1.SELinuxOptions)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SELinuxContextStrategyOptions.
func (in *SELinuxContextStrategyOptions) DeepCopy() *SELinuxContextStrategyOptions {
if in == nil {
return nil
}
out := new(SELinuxContextStrategyOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SecurityContextConstraints) DeepCopyInto(out *SecurityContextConstraints) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.Priority != nil {
in, out := &in.Priority, &out.Priority
*out = new(int32)
**out = **in
}
if in.DefaultAddCapabilities != nil {
in, out := &in.DefaultAddCapabilities, &out.DefaultAddCapabilities
*out = make([]corev1.Capability, len(*in))
copy(*out, *in)
}
if in.RequiredDropCapabilities != nil {
in, out := &in.RequiredDropCapabilities, &out.RequiredDropCapabilities
*out = make([]corev1.Capability, len(*in))
copy(*out, *in)
}
if in.AllowedCapabilities != nil {
in, out := &in.AllowedCapabilities, &out.AllowedCapabilities
*out = make([]corev1.Capability, len(*in))
copy(*out, *in)
}
if in.Volumes != nil {
in, out := &in.Volumes, &out.Volumes
*out = make([]FSType, len(*in))
copy(*out, *in)
}
if in.AllowedFlexVolumes != nil {
in, out := &in.AllowedFlexVolumes, &out.AllowedFlexVolumes
*out = make([]AllowedFlexVolume, len(*in))
copy(*out, *in)
}
if in.DefaultAllowPrivilegeEscalation != nil {
in, out := &in.DefaultAllowPrivilegeEscalation, &out.DefaultAllowPrivilegeEscalation
*out = new(bool)
**out = **in
}
if in.AllowPrivilegeEscalation != nil {
in, out := &in.AllowPrivilegeEscalation, &out.AllowPrivilegeEscalation
*out = new(bool)
**out = **in
}
in.SELinuxContext.DeepCopyInto(&out.SELinuxContext)
in.RunAsUser.DeepCopyInto(&out.RunAsUser)
in.SupplementalGroups.DeepCopyInto(&out.SupplementalGroups)
in.FSGroup.DeepCopyInto(&out.FSGroup)
if in.Users != nil {
in, out := &in.Users, &out.Users
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Groups != nil {
in, out := &in.Groups, &out.Groups
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.SeccompProfiles != nil {
in, out := &in.SeccompProfiles, &out.SeccompProfiles
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.AllowedUnsafeSysctls != nil {
in, out := &in.AllowedUnsafeSysctls, &out.AllowedUnsafeSysctls
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.ForbiddenSysctls != nil {
in, out := &in.ForbiddenSysctls, &out.ForbiddenSysctls
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityContextConstraints.
func (in *SecurityContextConstraints) DeepCopy() *SecurityContextConstraints {
if in == nil {
return nil
}
out := new(SecurityContextConstraints)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *SecurityContextConstraints) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SecurityContextConstraintsList) DeepCopyInto(out *SecurityContextConstraintsList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]SecurityContextConstraints, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityContextConstraintsList.
func (in *SecurityContextConstraintsList) DeepCopy() *SecurityContextConstraintsList {
if in == nil {
return nil
}
out := new(SecurityContextConstraintsList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *SecurityContextConstraintsList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServiceAccountPodSecurityPolicyReviewStatus) DeepCopyInto(out *ServiceAccountPodSecurityPolicyReviewStatus) {
*out = *in
in.PodSecurityPolicySubjectReviewStatus.DeepCopyInto(&out.PodSecurityPolicySubjectReviewStatus)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceAccountPodSecurityPolicyReviewStatus.
func (in *ServiceAccountPodSecurityPolicyReviewStatus) DeepCopy() *ServiceAccountPodSecurityPolicyReviewStatus {
if in == nil {
return nil
}
out := new(ServiceAccountPodSecurityPolicyReviewStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SupplementalGroupsStrategyOptions) DeepCopyInto(out *SupplementalGroupsStrategyOptions) {
*out = *in
if in.Ranges != nil {
in, out := &in.Ranges, &out.Ranges
*out = make([]IDRange, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SupplementalGroupsStrategyOptions.
func (in *SupplementalGroupsStrategyOptions) DeepCopy() *SupplementalGroupsStrategyOptions {
if in == nil {
return nil
}
out := new(SupplementalGroupsStrategyOptions)
in.DeepCopyInto(out)
return out
}

View File

@ -0,0 +1,228 @@
package v1
// This file contains a collection of methods that can be used from go-restful to
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
var map_AllowedFlexVolume = map[string]string{
"": "AllowedFlexVolume represents a single Flexvolume that is allowed to be used.",
"driver": "Driver is the name of the Flexvolume driver.",
}
func (AllowedFlexVolume) SwaggerDoc() map[string]string {
return map_AllowedFlexVolume
}
var map_FSGroupStrategyOptions = map[string]string{
"": "FSGroupStrategyOptions defines the strategy type and options used to create the strategy.",
"type": "Type is the strategy that will dictate what FSGroup is used in the SecurityContext.",
"ranges": "Ranges are the allowed ranges of fs groups. If you would like to force a single fs group then supply a single range with the same start and end.",
}
func (FSGroupStrategyOptions) SwaggerDoc() map[string]string {
return map_FSGroupStrategyOptions
}
var map_IDRange = map[string]string{
"": "IDRange provides a min/max of an allowed range of IDs.",
"min": "Min is the start of the range, inclusive.",
"max": "Max is the end of the range, inclusive.",
}
func (IDRange) SwaggerDoc() map[string]string {
return map_IDRange
}
var map_PodSecurityPolicyReview = map[string]string{
"": "PodSecurityPolicyReview checks which service accounts (not users, since that would be cluster-wide) can create the `PodTemplateSpec` in question.",
"spec": "spec is the PodSecurityPolicy to check.",
"status": "status represents the current information/status for the PodSecurityPolicyReview.",
}
func (PodSecurityPolicyReview) SwaggerDoc() map[string]string {
return map_PodSecurityPolicyReview
}
var map_PodSecurityPolicyReviewSpec = map[string]string{
"": "PodSecurityPolicyReviewSpec defines specification for PodSecurityPolicyReview",
"template": "template is the PodTemplateSpec to check. The template.spec.serviceAccountName field is used if serviceAccountNames is empty, unless the template.spec.serviceAccountName is empty, in which case \"default\" is used. If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.",
"serviceAccountNames": "serviceAccountNames is an optional set of ServiceAccounts to run the check with. If serviceAccountNames is empty, the template.spec.serviceAccountName is used, unless it's empty, in which case \"default\" is used instead. If serviceAccountNames is specified, template.spec.serviceAccountName is ignored.",
}
func (PodSecurityPolicyReviewSpec) SwaggerDoc() map[string]string {
return map_PodSecurityPolicyReviewSpec
}
var map_PodSecurityPolicyReviewStatus = map[string]string{
"": "PodSecurityPolicyReviewStatus represents the status of PodSecurityPolicyReview.",
"allowedServiceAccounts": "allowedServiceAccounts returns the list of service accounts in *this* namespace that have the power to create the PodTemplateSpec.",
}
func (PodSecurityPolicyReviewStatus) SwaggerDoc() map[string]string {
return map_PodSecurityPolicyReviewStatus
}
var map_PodSecurityPolicySelfSubjectReview = map[string]string{
"": "PodSecurityPolicySelfSubjectReview checks whether this user/SA tuple can create the PodTemplateSpec",
"spec": "spec defines specification the PodSecurityPolicySelfSubjectReview.",
"status": "status represents the current information/status for the PodSecurityPolicySelfSubjectReview.",
}
func (PodSecurityPolicySelfSubjectReview) SwaggerDoc() map[string]string {
return map_PodSecurityPolicySelfSubjectReview
}
var map_PodSecurityPolicySelfSubjectReviewSpec = map[string]string{
"": "PodSecurityPolicySelfSubjectReviewSpec contains specification for PodSecurityPolicySelfSubjectReview.",
"template": "template is the PodTemplateSpec to check.",
}
func (PodSecurityPolicySelfSubjectReviewSpec) SwaggerDoc() map[string]string {
return map_PodSecurityPolicySelfSubjectReviewSpec
}
var map_PodSecurityPolicySubjectReview = map[string]string{
"": "PodSecurityPolicySubjectReview checks whether a particular user/SA tuple can create the PodTemplateSpec.",
"spec": "spec defines specification for the PodSecurityPolicySubjectReview.",
"status": "status represents the current information/status for the PodSecurityPolicySubjectReview.",
}
func (PodSecurityPolicySubjectReview) SwaggerDoc() map[string]string {
return map_PodSecurityPolicySubjectReview
}
var map_PodSecurityPolicySubjectReviewSpec = map[string]string{
"": "PodSecurityPolicySubjectReviewSpec defines specification for PodSecurityPolicySubjectReview",
"template": "template is the PodTemplateSpec to check. If template.spec.serviceAccountName is empty it will not be defaulted. If its non-empty, it will be checked.",
"user": "user is the user you're testing for. If you specify \"user\" but not \"group\", then is it interpreted as \"What if user were not a member of any groups. If user and groups are empty, then the check is performed using *only* the serviceAccountName in the template.",
"groups": "groups is the groups you're testing for.",
}
func (PodSecurityPolicySubjectReviewSpec) SwaggerDoc() map[string]string {
return map_PodSecurityPolicySubjectReviewSpec
}
var map_PodSecurityPolicySubjectReviewStatus = map[string]string{
"": "PodSecurityPolicySubjectReviewStatus contains information/status for PodSecurityPolicySubjectReview.",
"allowedBy": "allowedBy is a reference to the rule that allows the PodTemplateSpec. A rule can be a SecurityContextConstraint or a PodSecurityPolicy A `nil`, indicates that it was denied.",
"reason": "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available.",
"template": "template is the PodTemplateSpec after the defaulting is applied.",
}
func (PodSecurityPolicySubjectReviewStatus) SwaggerDoc() map[string]string {
return map_PodSecurityPolicySubjectReviewStatus
}
var map_RangeAllocation = map[string]string{
"": "RangeAllocation is used so we can easily expose a RangeAllocation typed for security group",
"metadata": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
"range": "range is a string representing a unique label for a range of uids, \"1000000000-2000000000/10000\".",
"data": "data is a byte array representing the serialized state of a range allocation. It is a bitmap with each bit set to one to represent a range is taken.",
}
func (RangeAllocation) SwaggerDoc() map[string]string {
return map_RangeAllocation
}
var map_RangeAllocationList = map[string]string{
"": "RangeAllocationList is a list of RangeAllocations objects",
"metadata": "More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"items": "List of RangeAllocations.",
}
func (RangeAllocationList) SwaggerDoc() map[string]string {
return map_RangeAllocationList
}
var map_RunAsUserStrategyOptions = map[string]string{
"": "RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.",
"type": "Type is the strategy that will dictate what RunAsUser is used in the SecurityContext.",
"uid": "UID is the user id that containers must run as. Required for the MustRunAs strategy if not using namespace/service account allocated uids.",
"uidRangeMin": "UIDRangeMin defines the min value for a strategy that allocates by range.",
"uidRangeMax": "UIDRangeMax defines the max value for a strategy that allocates by range.",
}
func (RunAsUserStrategyOptions) SwaggerDoc() map[string]string {
return map_RunAsUserStrategyOptions
}
var map_SELinuxContextStrategyOptions = map[string]string{
"": "SELinuxContextStrategyOptions defines the strategy type and any options used to create the strategy.",
"type": "Type is the strategy that will dictate what SELinux context is used in the SecurityContext.",
"seLinuxOptions": "seLinuxOptions required to run as; required for MustRunAs",
}
func (SELinuxContextStrategyOptions) SwaggerDoc() map[string]string {
return map_SELinuxContextStrategyOptions
}
var map_SecurityContextConstraints = map[string]string{
"": "SecurityContextConstraints governs the ability to make requests that affect the SecurityContext that will be applied to a container. For historical reasons SCC was exposed under the core Kubernetes API group. That exposure is deprecated and will be removed in a future release - users should instead use the security.openshift.io group to manage SecurityContextConstraints.",
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"priority": "Priority influences the sort order of SCCs when evaluating which SCCs to try first for a given pod request based on access in the Users and Groups fields. The higher the int, the higher priority. An unset value is considered a 0 priority. If scores for multiple SCCs are equal they will be sorted from most restrictive to least restrictive. If both priorities and restrictions are equal the SCCs will be sorted by name.",
"allowPrivilegedContainer": "AllowPrivilegedContainer determines if a container can request to be run as privileged.",
"defaultAddCapabilities": "DefaultAddCapabilities is the default set of capabilities that will be added to the container unless the pod spec specifically drops the capability. You may not list a capabiility in both DefaultAddCapabilities and RequiredDropCapabilities.",
"requiredDropCapabilities": "RequiredDropCapabilities are the capabilities that will be dropped from the container. These are required to be dropped and cannot be added.",
"allowedCapabilities": "AllowedCapabilities is a list of capabilities that can be requested to add to the container. Capabilities in this field maybe added at the pod author's discretion. You must not list a capability in both AllowedCapabilities and RequiredDropCapabilities. To allow all capabilities you may use '*'.",
"allowHostDirVolumePlugin": "AllowHostDirVolumePlugin determines if the policy allow containers to use the HostDir volume plugin",
"volumes": "Volumes is a white list of allowed volume plugins. FSType corresponds directly with the field names of a VolumeSource (azureFile, configMap, emptyDir). To allow all volumes you may use \"*\". To allow no volumes, set to [\"none\"].",
"allowedFlexVolumes": "AllowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes is allowed in the \"Volumes\" field.",
"allowHostNetwork": "AllowHostNetwork determines if the policy allows the use of HostNetwork in the pod spec.",
"allowHostPorts": "AllowHostPorts determines if the policy allows host ports in the containers.",
"allowHostPID": "AllowHostPID determines if the policy allows host pid in the containers.",
"allowHostIPC": "AllowHostIPC determines if the policy allows host ipc in the containers.",
"defaultAllowPrivilegeEscalation": "DefaultAllowPrivilegeEscalation controls the default setting for whether a process can gain more privileges than its parent process.",
"allowPrivilegeEscalation": "AllowPrivilegeEscalation determines if a pod can request to allow privilege escalation. If unspecified, defaults to true.",
"seLinuxContext": "SELinuxContext is the strategy that will dictate what labels will be set in the SecurityContext.",
"runAsUser": "RunAsUser is the strategy that will dictate what RunAsUser is used in the SecurityContext.",
"supplementalGroups": "SupplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.",
"fsGroup": "FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.",
"readOnlyRootFilesystem": "ReadOnlyRootFilesystem when set to true will force containers to run with a read only root file system. If the container specifically requests to run with a non-read only root file system the SCC should deny the pod. If set to false the container may run with a read only root file system if it wishes but it will not be forced to.",
"users": "The users who have permissions to use this security context constraints",
"groups": "The groups that have permission to use this security context constraints",
"seccompProfiles": "SeccompProfiles lists the allowed profiles that may be set for the pod or container's seccomp annotations. An unset (nil) or empty value means that no profiles may be specifid by the pod or container.\tThe wildcard '*' may be used to allow all profiles. When used to generate a value for a pod the first non-wildcard profile will be used as the default.",
"allowedUnsafeSysctls": "AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none. Each entry is either a plain sysctl name or ends in \"*\" in which case it is considered as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed. Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.\n\nExamples: e.g. \"foo/*\" allows \"foo/bar\", \"foo/baz\", etc. e.g. \"foo.*\" allows \"foo.bar\", \"foo.baz\", etc.",
"forbiddenSysctls": "ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none. Each entry is either a plain sysctl name or ends in \"*\" in which case it is considered as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.\n\nExamples: e.g. \"foo/*\" forbids \"foo/bar\", \"foo/baz\", etc. e.g. \"foo.*\" forbids \"foo.bar\", \"foo.baz\", etc.",
}
func (SecurityContextConstraints) SwaggerDoc() map[string]string {
return map_SecurityContextConstraints
}
var map_SecurityContextConstraintsList = map[string]string{
"": "SecurityContextConstraintsList is a list of SecurityContextConstraints objects",
"metadata": "More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"items": "List of security context constraints.",
}
func (SecurityContextConstraintsList) SwaggerDoc() map[string]string {
return map_SecurityContextConstraintsList
}
var map_ServiceAccountPodSecurityPolicyReviewStatus = map[string]string{
"": "ServiceAccountPodSecurityPolicyReviewStatus represents ServiceAccount name and related review status",
"name": "name contains the allowed and the denied ServiceAccount name",
}
func (ServiceAccountPodSecurityPolicyReviewStatus) SwaggerDoc() map[string]string {
return map_ServiceAccountPodSecurityPolicyReviewStatus
}
var map_SupplementalGroupsStrategyOptions = map[string]string{
"": "SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.",
"type": "Type is the strategy that will dictate what supplemental groups is used in the SecurityContext.",
"ranges": "Ranges are the allowed ranges of supplemental groups. If you would like to force a single supplemental group then supply a single range with the same start and end.",
}
func (SupplementalGroupsStrategyOptions) SwaggerDoc() map[string]string {
return map_SupplementalGroupsStrategyOptions
}
// AUTO-GENERATED FUNCTIONS END HERE

1
vendor/modules.txt vendored
View File

@ -118,6 +118,7 @@ github.com/openshift/api/console/v1
github.com/openshift/api/oauth/v1
github.com/openshift/api/project/v1
github.com/openshift/api/route/v1
github.com/openshift/api/security/v1
github.com/openshift/api/user/v1
# github.com/operator-framework/api v0.10.0 => github.com/operator-framework/api v0.10.0
## explicit