Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(provider/k8s): Prepare these new fileds or files for the statefu… #1853

Merged
merged 4 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ class KubernetesApiConverter {
deployDescription.namespace = replicaSet?.metadata?.namespace
deployDescription.targetSize = replicaSet?.spec?.replicas
deployDescription.securityGroups = []
deployDescription.replicaSetAnnotations = replicaSet?.metadata?.annotations
deployDescription.controllerAnnotations = replicaSet?.metadata?.annotations
deployDescription.podAnnotations = replicaSet?.spec?.template?.metadata?.annotations

deployDescription.volumeSources = replicaSet?.spec?.template?.spec?.volumes?.collect {
Expand Down Expand Up @@ -812,7 +812,7 @@ class KubernetesApiConverter {

return serverGroupBuilder.withNewMetadata()
.withName(replicaSetName)
.withAnnotations(description.replicaSetAnnotations)
.withAnnotations(description.controllerAnnotations)
.endMetadata()
.withNewSpec()
.withNewSelector()
Expand All @@ -833,7 +833,7 @@ class KubernetesApiConverter {

def builder = serverGroupBuilder.withNewMetadata()
.withName(parsedName.cluster)
.withAnnotations(description.replicaSetAnnotations)
.withAnnotations(description.controllerAnnotations)
.endMetadata()
.withNewSpec()
.withNewSelector()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class KubernetesClientApiConverter {
deployDescription.namespace = statefulSet?.metadata?.namespace
deployDescription.targetSize = statefulSet?.spec?.replicas
deployDescription.securityGroups = []
deployDescription.replicaSetAnnotations = statefulSet?.metadata?.annotations
deployDescription.controllerAnnotations = statefulSet?.metadata?.annotations
deployDescription.podAnnotations = statefulSet?.spec?.template?.metadata?.annotations
deployDescription.volumeClaims = statefulSet?.spec?.getVolumeClaimTemplates()
deployDescription.volumeSources = statefulSet?.spec?.template?.spec?.volumes?.collect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class KubernetesUtil {
static String DEPRECATED_SERVER_GROUP_KIND = "ReplicationController"
static String SERVER_GROUP_KIND = "ReplicaSet"
static String DEPLOYMENT_KIND = "Deployment"
static String CONTROLLERS_STATEFULSET_KIND = "StatefulSet"
static String CONTROLLERS_DAEMONSET_KIND = "DaemonSet"
static String JOB_LABEL = "job"
@Value("kubernetes.defaultRegistry:gcr.io")
static String DEFAULT_REGISTRY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ import groovy.transform.Canonical
class KubernetesAtomicOperationDescription implements DeployDescription, CredentialsNameable {
String account
KubernetesNamedAccountCredentials credentials
String kind
String apiVersion
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class DeployKubernetesAtomicOperationDescription extends KubernetesAtomicOperati
List<KubernetesVolumeSource> volumeSources
Capacity capacity
KubernetesScalingPolicy scalingPolicy
Map<String, String> replicaSetAnnotations
Map<String, String> controllerAnnotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing users. They expect the field replicaSetAnnotations

Map<String, String> podAnnotations
Map<String, String> volumeAnnotations
Map<String, String> nodeSelector
KubernetesSecurityContext securityContext
KubernetesDeployment deployment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2017 Cisco, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.clouddriver.kubernetes.model

import io.fabric8.kubernetes.api.model.HasMetadata
import io.fabric8.kubernetes.api.model.ObjectMeta
import io.kubernetes.client.models.V1ObjectMeta

class KubernetesControllerConverter implements HasMetadata {
String kind
String apiVersion
ObjectMeta metadata

KubernetesControllerConverter(String kind, String apiVersion, V1ObjectMeta metadata) {
this.kind = kind
this.apiVersion = apiVersion

this.metadata = new ObjectMeta()
this.metadata.name = metadata.name
this.metadata.namespace = metadata.namespace
ObjectMeta mdata = new ObjectMeta()
mdata.name = metadata.name
mdata.namespace = metadata.namespace
setMetadata(mdata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you are just setting these fields twice here. Once above with this.metadata... and again here by creating a new object and assigning it.

}

@Override
ObjectMeta getMetadata() {
return this.metadata
}

@Override
void setMetadata(ObjectMeta metadata) {
this.metadata = metadata
}

@Override
String getKind() {
return this.kind
}

@Override
String getApiVersion() {
return this.apiVersion
}
}