public static void main(String[] args) throws InterruptedException {

        try (OpenShiftClient client = new DefaultOpenShiftClient()) {

          SecurityContextConstraints scc = new SecurityContextConstraintsBuilder()
            .withNewMetadata().withName("scc").endMetadata()
            .withAllowPrivilegedContainer(true)
            .withNewRunAsUser()
            .withType("RunAsAny")
            .endRunAsUser()
            .withNewSeLinuxContext()
            .withType("RunAsAny")
            .endSeLinuxContext()
            .withNewFsGroup()
            .withType("RunAsAny")
            .endFsGroup()
            .withNewSupplementalGroups()
            .withType("RunAsAny")
            .endSupplementalGroups()
            .addToUsers("admin")
            .addToGroups("admin-group")
            .build();

          log("Created SecurityContextConstraints", client.securityContextConstraints().create(scc));

          client.close();

        } catch (KubernetesClientException e) {
          logger.error(e.getMessage(), e);
        }
    }
public static void main ( String [ ] args ) throws InterruptedException { try ( OpenShiftClient client = new DefaultOpenShiftClient ( ) ) { SecurityContextConstraints scc = new SecurityContextConstraintsBuilder ( ) . withNewMetadata ( ) . withName ( "scc" ) . endMetadata ( ) . withAllowPrivilegedContainer ( true ) . withNewRunAsUser ( ) . withType ( "RunAsAny" ) . endRunAsUser ( ) . withNewSeLinuxContext ( ) . withType ( "RunAsAny" ) . endSeLinuxContext ( ) . withNewFsGroup ( ) . withType ( "RunAsAny" ) . endFsGroup ( ) . withNewSupplementalGroups ( ) . withType ( "RunAsAny" ) . endSupplementalGroups ( ) . addToUsers ( "admin" ) . addToGroups ( "admin-group" ) . build ( ) ; log ( "Created SecurityContextConstraints" , client . securityContextConstraints ( ) . create ( scc ) ) ; client . close ( ) ; } catch ( KubernetesClientException e ) { logger . error ( e . getMessage ( ) , e ) ; } }
oc login -u system:admin