本文整理汇总了Java中io.fabric8.kubernetes.api.model.ObjectMeta.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMeta.setName方法的具体用法?Java ObjectMeta.setName怎么用?Java ObjectMeta.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.fabric8.kubernetes.api.model.ObjectMeta
的用法示例。
在下文中一共展示了ObjectMeta.setName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createService
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Service createService(final String namespace,
final String serviceName,
Map<String, String> labels) {
labels = normalizeLabels(labels);
final Service service = new Service();
final ObjectMeta metadata = new ObjectMeta();
metadata.setNamespace(normalizeNamespace(namespace));
metadata.setName(normalizeServiceName(serviceName));
metadata.setLabels(labels);
service.setMetadata(metadata);
service.setSpec(this.createServiceSpec(labels));
return service;
}
示例2: createDeployment
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Deployment createDeployment(String namespace,
final String deploymentName,
Map<String, String> labels,
final String serviceAccountName,
final String imageName,
final ImagePullPolicy imagePullPolicy,
final boolean hostNetwork,
final boolean tls,
final boolean verifyTls) {
namespace = normalizeNamespace(namespace);
labels = normalizeLabels(labels);
final Deployment deployment = new Deployment();
final ObjectMeta metadata = new ObjectMeta();
metadata.setNamespace(namespace);
metadata.setName(normalizeDeploymentName(deploymentName));
metadata.setLabels(labels);
deployment.setMetadata(metadata);
deployment.setSpec(this.createDeploymentSpec(labels, serviceAccountName, imageName, imagePullPolicy, namespace, hostNetwork, tls, verifyTls));
return deployment;
}
示例3: newPod
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private Pod newPod(String uid, String namespace, String name, String node) {
Pod pod = new Pod();
ObjectMeta objMeta = new ObjectMeta();
objMeta.setName(name);
objMeta.setNamespace(namespace);
objMeta.setUid(uid);
PodSpec spec = new PodSpec();
spec.setNodeName(node);
pod.setMetadata(objMeta);
pod.setSpec(spec);
return pod;
}
示例4: fakeServiceAccountKeySecret
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private static Secret fakeServiceAccountKeySecret(String serviceAccount, long epoch, String jsonKeyId,
String p12KeyId, String creationTimestamp) {
final String jsonKeyName = keyName(serviceAccount, jsonKeyId);
final String p12KeyName = keyName(serviceAccount, p12KeyId);
final ObjectMeta metadata = new ObjectMeta();
metadata.setCreationTimestamp(creationTimestamp);
metadata.setName("styx-wf-sa-keys-" + epoch + "-" + Hashing.sha256().hashString(serviceAccount, UTF_8));
metadata.setAnnotations(ImmutableMap.of(
"styx-wf-sa", serviceAccount,
"styx-wf-sa-json-key-name", jsonKeyName,
"styx-wf-sa-p12-key-name", p12KeyName));
return new SecretBuilder()
.withMetadata(metadata)
.withData(ImmutableMap.of(
"styx-wf-sa.json", "json-private-key-data",
"styx-wf-sa.p12", "p12-private-key-data"))
.build();
}
示例5: provision
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
throws InfrastructureException {
final String workspaceId = identity.getWorkspaceId();
final Set<Pod> pods = new HashSet<>(osEnv.getPods().values());
osEnv.getPods().clear();
for (Pod pod : pods) {
final ObjectMeta podMeta = pod.getMetadata();
putLabel(pod, Constants.CHE_ORIGINAL_NAME_LABEL, podMeta.getName());
final String podName = Names.uniquePodName(podMeta.getName(), workspaceId);
podMeta.setName(podName);
osEnv.getPods().put(podName, pod);
}
final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
osEnv.getRoutes().clear();
for (Route route : routes) {
final ObjectMeta routeMeta = route.getMetadata();
putLabel(route, Constants.CHE_ORIGINAL_NAME_LABEL, routeMeta.getName());
final String routeName = Names.uniqueRouteName();
routeMeta.setName(routeName);
osEnv.getRoutes().put(routeName, route);
}
}
示例6: getNodes
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Override
public NodeList getNodes() {
// TODO we should replace HostNode with Node...
NodeList answer = new NodeList();
List<Node> items = new ArrayList<>();
answer.setItems(items);
Collection<HostNode> values = getHostNodes().values();
for (HostNode value : values) {
Node minion = new Node();
NodeSpec nodeSpec = new NodeSpec();
minion.setSpec(nodeSpec);
ObjectMeta metadata = new ObjectMeta();
metadata.setName(value.getId());
minion.setMetadata(metadata);
// TODO no hostName on a minion
//minion.setHostIP(value.getHostName());
items.add(minion);
}
return answer;
}
示例7: createSecret
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Secret createSecret(final String namespace,
final URI tlsKeyUri,
final URI tlsCertUri,
final URI tlsCaCertUri,
final Map<String, String> labels)
throws IOException {
final Secret secret = new Secret();
secret.setType("Opaque");
final Map<String, String> secretData = new HashMap<>();
try (final InputStream tlsKeyStream = read(tlsKeyUri)) {
if (tlsKeyStream != null) {
secretData.put("tls.key", Base64.getEncoder().encodeToString(toByteArray(tlsKeyStream)));
}
}
try (final InputStream tlsCertStream = read(tlsCertUri)) {
if (tlsCertStream != null) {
secretData.put("tls.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCertStream)));
}
}
try (final InputStream tlsCaCertStream = read(tlsCaCertUri)) {
if (tlsCaCertStream != null) {
secretData.put("ca.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCaCertStream)));
}
}
secret.setData(secretData);
final ObjectMeta metadata = new ObjectMeta();
metadata.setNamespace(normalizeNamespace(namespace));
metadata.setName(SECRET_NAME);
metadata.setLabels(normalizeLabels(labels));
secret.setMetadata(metadata);
return secret;
}
示例8: newDeployment
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private Deployment newDeployment(String uid, String namespace, String name, int desiredReplicaCount, String containerImageName) {
Deployment deployment = new Deployment();
ObjectMeta objMeta = new ObjectMeta();
objMeta.setName(name);
objMeta.setNamespace(namespace);
objMeta.setUid(uid);
DeploymentSpec spec = new DeploymentSpec();
spec.setReplicas(desiredReplicaCount);
Container container = new Container();
container.setImage(containerImageName);
PodSpec podSpec = new PodSpec();
podSpec.setContainers(Arrays.asList(container));
PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
podTemplateSpec.setSpec(podSpec);
spec.setTemplate(podTemplateSpec);
deployment.setMetadata(objMeta);
deployment.setSpec(spec);
DeploymentStatus deploymentStatus = new DeploymentStatus();
deploymentStatus.setAvailableReplicas(3);
deployment.setStatus(deploymentStatus);
return deployment;
}
示例9: testGetStartedTime
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Test
public void testGetStartedTime() throws Exception {
KubeCloudImage image = m.mock(KubeCloudImage.class);
ObjectMeta metadata = new ObjectMeta();
metadata.setName("foo");
Pod pod = new Pod("1.0", "kind", metadata, new PodSpec(), new PodStatusBuilder().withStartTime("2017-06-12T22:59Z").build());
m.checking(new Expectations(){{
allowing(myApi).getPodStatus(with("foo")); will(returnValue(pod.getStatus()));
}});
KubeCloudInstanceImpl instance = new KubeCloudInstanceImpl(image, pod, myApi);
Date startedTime = instance.getStartedTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("2017-06-12T22:59Z", dateFormat.format(startedTime));
}
示例10: createPod
import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@VisibleForTesting
Pod createPod(RunSpec runSpec) {
final String podName = HYPE_RUN + "-" + randomAlphaNumeric(8);
final RunEnvironment env = runSpec.runEnvironment();
final List<Secret> secrets = env.secretMounts();
final StagedContinuation stagedContinuation = runSpec.stagedContinuation();
final List<VolumeMountInfo> volumeMountInfos = volumeMountInfos(env.volumeMounts());
final Pod basePod = getBasePod(env, runSpec.image());
// add metadata name
final ObjectMeta metadata = basePod.getMetadata() != null
? basePod.getMetadata()
: new ObjectMeta();
metadata.setName(podName);
basePod.setMetadata(metadata);
final PodSpec spec = basePod.getSpec();
// add volumes
secrets.forEach(s ->
spec.getVolumes()
.add(new VolumeBuilder()
.withName(s.name())
.withNewSecret()
.withSecretName(s.name())
.endSecret()
.build()));
volumeMountInfos.stream()
.map(VolumeMountInfo::volume)
.forEach(spec.getVolumes()::add);
final Container container = findHypeRunContainer(basePod);
// add volume mounts
secrets.forEach(s ->
container.getVolumeMounts()
.add(new VolumeMountBuilder()
.withName(s.name())
.withMountPath(s.mountPath())
.withReadOnly(true)
.build()));
volumeMountInfos.stream()
.map(VolumeMountInfo::volumeMount)
.forEach(container.getVolumeMounts()::add);
// set args
if (container.getArgs().size() > 0) {
LOG.warn("Overriding " + HYPE_RUN + " container args");
}
container.setArgs(singletonList(stagedContinuation.manifestPath().toUri().toString()));
// add env var
container.getEnv()
.add(new EnvVarBuilder()
.withName(EXECUTION_ID)
.withValue(podName)
.build());
// add resource requests
final ResourceRequirementsBuilder resourceReqsBuilder = container.getResources() != null
? new ResourceRequirementsBuilder(
container.getResources())
: new ResourceRequirementsBuilder();
for (Map.Entry<String, String> request : env.resourceRequests().entrySet()) {
resourceReqsBuilder.addToRequests(request.getKey(), new Quantity(request.getValue()));
}
container.setResources(resourceReqsBuilder.build());
return basePod;
}