-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider/kubernetes): v2 Add support for RBAC resource kinds (#2419
) Adds support for ClusterRole, ClusterRoleBinding, Role, RoleBinding and ServiceAccount resource kinds. Cluster-level resources like Role, ClusterRoleBinding, PersistentVolume, etc. do belong to any namespace, so we also add support for resource kinds without namespaces. Previously the "namespace" resource kind was the only kind which did not belong to a namespace.
- Loading branch information
Showing
15 changed files
with
603 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ker/clouddriver/kubernetes/v2/caching/agent/KubernetesClusterRoleBindingCachingAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Joel Wilsson | ||
* | ||
* 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.v2.caching.agent; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spinnaker.cats.agent.AgentDataType; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.Keys; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesV2Credentials; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE; | ||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE; | ||
|
||
public class KubernetesClusterRoleBindingCachingAgent extends KubernetesV2OnDemandCachingAgent { | ||
KubernetesClusterRoleBindingCachingAgent(KubernetesNamedAccountCredentials<KubernetesV2Credentials> namedAccountCredentials, | ||
ObjectMapper objectMapper, | ||
Registry registry, | ||
int agentIndex, | ||
int agentCount) { | ||
super(namedAccountCredentials, objectMapper, registry, agentIndex, agentCount); | ||
} | ||
|
||
@Getter | ||
final private Collection<AgentDataType> providedDataTypes = Collections.unmodifiableSet( | ||
new HashSet<>(Arrays.asList( | ||
AUTHORITATIVE.forType(KubernetesKind.CLUSTER_ROLE_BINDING.toString()) | ||
)) | ||
); | ||
|
||
@Override | ||
protected boolean hasClusterRelationship() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected KubernetesKind primaryKind() { | ||
return KubernetesKind.CLUSTER_ROLE_BINDING; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
.../spinnaker/clouddriver/kubernetes/v2/caching/agent/KubernetesClusterRoleCachingAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Joel Wilsson | ||
* | ||
* 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.v2.caching.agent; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spinnaker.cats.agent.AgentDataType; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.Keys; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesV2Credentials; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE; | ||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE; | ||
|
||
public class KubernetesClusterRoleCachingAgent extends KubernetesV2OnDemandCachingAgent { | ||
KubernetesClusterRoleCachingAgent(KubernetesNamedAccountCredentials<KubernetesV2Credentials> namedAccountCredentials, | ||
ObjectMapper objectMapper, | ||
Registry registry, | ||
int agentIndex, | ||
int agentCount) { | ||
super(namedAccountCredentials, objectMapper, registry, agentIndex, agentCount); | ||
} | ||
|
||
@Getter | ||
final private Collection<AgentDataType> providedDataTypes = Collections.unmodifiableSet( | ||
new HashSet<>(Arrays.asList( | ||
AUTHORITATIVE.forType(KubernetesKind.CLUSTER_ROLE.toString()) | ||
)) | ||
); | ||
|
||
@Override | ||
protected boolean hasClusterRelationship() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected KubernetesKind primaryKind() { | ||
return KubernetesKind.CLUSTER_ROLE; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
.../spinnaker/clouddriver/kubernetes/v2/caching/agent/KubernetesRoleBindingCachingAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Joel Wilsson | ||
* | ||
* 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.v2.caching.agent; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spinnaker.cats.agent.AgentDataType; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.Keys; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesV2Credentials; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE; | ||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE; | ||
|
||
public class KubernetesRoleBindingCachingAgent extends KubernetesV2OnDemandCachingAgent { | ||
KubernetesRoleBindingCachingAgent(KubernetesNamedAccountCredentials<KubernetesV2Credentials> namedAccountCredentials, | ||
ObjectMapper objectMapper, | ||
Registry registry, | ||
int agentIndex, | ||
int agentCount) { | ||
super(namedAccountCredentials, objectMapper, registry, agentIndex, agentCount); | ||
} | ||
|
||
@Getter | ||
final private Collection<AgentDataType> providedDataTypes = Collections.unmodifiableSet( | ||
new HashSet<>(Arrays.asList( | ||
AUTHORITATIVE.forType(KubernetesKind.ROLE_BINDING.toString()) | ||
)) | ||
); | ||
|
||
@Override | ||
protected boolean hasClusterRelationship() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected KubernetesKind primaryKind() { | ||
return KubernetesKind.ROLE_BINDING; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...netflix/spinnaker/clouddriver/kubernetes/v2/caching/agent/KubernetesRoleCachingAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Joel Wilsson | ||
* | ||
* 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.v2.caching.agent; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spinnaker.cats.agent.AgentDataType; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.Keys; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesV2Credentials; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE; | ||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE; | ||
|
||
public class KubernetesRoleCachingAgent extends KubernetesV2OnDemandCachingAgent { | ||
KubernetesRoleCachingAgent(KubernetesNamedAccountCredentials<KubernetesV2Credentials> namedAccountCredentials, | ||
ObjectMapper objectMapper, | ||
Registry registry, | ||
int agentIndex, | ||
int agentCount) { | ||
super(namedAccountCredentials, objectMapper, registry, agentIndex, agentCount); | ||
} | ||
|
||
@Getter | ||
final private Collection<AgentDataType> providedDataTypes = Collections.unmodifiableSet( | ||
new HashSet<>(Arrays.asList( | ||
AUTHORITATIVE.forType(KubernetesKind.ROLE.toString()) | ||
)) | ||
); | ||
|
||
@Override | ||
protected boolean hasClusterRelationship() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected KubernetesKind primaryKind() { | ||
return KubernetesKind.ROLE; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...innaker/clouddriver/kubernetes/v2/caching/agent/KubernetesServiceAccountCachingAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Joel Wilsson | ||
* | ||
* 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.v2.caching.agent; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.netflix.spectator.api.Registry; | ||
import com.netflix.spinnaker.cats.agent.AgentDataType; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.Keys; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesKind; | ||
import com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesV2Credentials; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE; | ||
import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE; | ||
|
||
public class KubernetesServiceAccountCachingAgent extends KubernetesV2OnDemandCachingAgent { | ||
KubernetesServiceAccountCachingAgent(KubernetesNamedAccountCredentials<KubernetesV2Credentials> namedAccountCredentials, | ||
ObjectMapper objectMapper, | ||
Registry registry, | ||
int agentIndex, | ||
int agentCount) { | ||
super(namedAccountCredentials, objectMapper, registry, agentIndex, agentCount); | ||
} | ||
|
||
@Getter | ||
final private Collection<AgentDataType> providedDataTypes = Collections.unmodifiableSet( | ||
new HashSet<>(Arrays.asList( | ||
AUTHORITATIVE.forType(KubernetesKind.SERVICE_ACCOUNT.toString()) | ||
)) | ||
); | ||
|
||
@Override | ||
protected boolean hasClusterRelationship() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected KubernetesKind primaryKind() { | ||
return KubernetesKind.SERVICE_ACCOUNT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.