Java Code Examples for io.fabric8.kubernetes.api.model.PodSpec#getSecurityContext()
The following examples show how to use
io.fabric8.kubernetes.api.model.PodSpec#getSecurityContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testPodSecurityContextProperty() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.podSecurityContext", "{runAsUser: 65534, fsGroup: 65534}"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); deployer = new KubernetesAppDeployer(new KubernetesDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertEquals("Unexpected run as user", Long.valueOf("65534"), podSecurityContext.getRunAsUser()); assertEquals("Unexpected fs group", Long.valueOf("65534"), podSecurityContext.getFsGroup()); }
Example 2
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testPodSecurityContextGlobalProperty() { AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), null); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); KubernetesDeployerProperties.PodSecurityContext securityContext = new KubernetesDeployerProperties.PodSecurityContext(); securityContext.setFsGroup(65534L); securityContext.setRunAsUser(65534L); kubernetesDeployerProperties.setPodSecurityContext(securityContext); deployer = new KubernetesAppDeployer(kubernetesDeployerProperties, null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertEquals("Unexpected run as user", Long.valueOf("65534"), podSecurityContext.getRunAsUser()); assertEquals("Unexpected fs group", Long.valueOf("65534"), podSecurityContext.getFsGroup()); }
Example 3
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testPodSecurityContextUIDOnly() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.podSecurityContext", "{runAsUser: 65534}"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); deployer = new KubernetesAppDeployer(new KubernetesDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertEquals("Unexpected run as user", Long.valueOf("65534"), podSecurityContext.getRunAsUser()); assertNull("Unexpected fs group", podSecurityContext.getFsGroup()); }
Example 4
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testPodSecurityContextFsGroupOnly() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.podSecurityContext", "{fsGroup: 65534}"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); deployer = new KubernetesAppDeployer(new KubernetesDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertNull("Unexpected run as user", podSecurityContext.getRunAsUser()); assertEquals("Unexpected fs group", Long.valueOf("65534"), podSecurityContext.getFsGroup()); }
Example 5
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testPodSecurityContextPropertyOverrideGlobal() { Map<String, String> props = new HashMap<>(); props.put("spring.cloud.deployer.kubernetes.podSecurityContext", "{runAsUser: 65534, fsGroup: 65534}"); AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props); KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties(); KubernetesDeployerProperties.PodSecurityContext securityContext = new KubernetesDeployerProperties.PodSecurityContext(); securityContext.setFsGroup(1000L); securityContext.setRunAsUser(1000L); kubernetesDeployerProperties.setPodSecurityContext(securityContext); deployer = new KubernetesAppDeployer(kubernetesDeployerProperties, null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertEquals("Unexpected run as user", Long.valueOf("65534"), podSecurityContext.getRunAsUser()); assertEquals("Unexpected fs group", Long.valueOf("65534"), podSecurityContext.getFsGroup()); }
Example 6
Source File: KubernetesAppDeployerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
@Test public void testPodSecurityContextFromYaml() throws Exception { AppDefinition definition = new AppDefinition("app-test", null); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), null); deployer = new KubernetesAppDeployer(bindDeployerProperties(), null); PodSpec podSpec = deployer.createPodSpec(appDeploymentRequest); PodSecurityContext podSecurityContext = podSpec.getSecurityContext(); assertNotNull("Pod security context should not be null", podSecurityContext); assertEquals("Unexpected run as user", Long.valueOf("65534"), podSecurityContext.getRunAsUser()); assertEquals("Unexpected fs group", Long.valueOf("65534"), podSecurityContext.getFsGroup()); }