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: Add support for ReplicaSet without duplicating whats created by Deployment #31

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 22 additions & 19 deletions eksup/src/k8s/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,35 @@ async fn get_deployments(client: &Client) -> Result<Vec<StdResource>> {
Ok(deployments)
}

async fn _get_replicasets(client: &Client) -> Result<Vec<StdResource>> {
async fn get_replicasets(client: &Client) -> Result<Vec<StdResource>> {
let api: Api<apps::v1::ReplicaSet> = Api::all(client.to_owned());
let replicaset_list = api.list(&Default::default()).await?;

let replicasets = replicaset_list
.items
.iter()
.map(|repl| {
let objmeta = repl.metadata.clone();
let spec = repl.spec.clone().unwrap();
.filter_map(|repl| match repl.metadata.owner_references {
None => {
let objmeta = repl.metadata.clone();
let spec = repl.spec.clone().unwrap();

let metadata = StdMetadata {
name: objmeta.name.unwrap(),
namespace: objmeta.namespace.unwrap(),
kind: Kind::ReplicaSet,
labels: objmeta.labels.unwrap_or_default(),
annotations: objmeta.annotations.unwrap_or_default(),
};
let metadata = StdMetadata {
name: objmeta.name.unwrap(),
namespace: objmeta.namespace.unwrap(),
kind: Kind::ReplicaSet,
labels: objmeta.labels.unwrap_or_default(),
annotations: objmeta.annotations.unwrap_or_default(),
};

let spec = StdSpec {
min_ready_seconds: spec.min_ready_seconds,
replicas: spec.replicas,
template: spec.template,
};
let spec = StdSpec {
min_ready_seconds: spec.min_ready_seconds,
replicas: spec.replicas,
template: spec.template,
};

StdResource { metadata, spec }
Some(StdResource { metadata, spec })
}
Some(_) => None,
})
.collect();

Expand Down Expand Up @@ -587,15 +590,15 @@ pub async fn get_resources(client: &Client) -> Result<Vec<StdResource>> {
let daemonsets = get_daemonsets(client).await?;
let deployments = get_deployments(client).await?;
let jobs = get_jobs(client).await?;
// let replicasets = get_replicasets(client).await?;
let replicasets = get_replicasets(client).await?;
let statefulsets = get_statefulsets(client).await?;

let mut resources = Vec::new();
resources.extend(cronjobs);
resources.extend(daemonsets);
resources.extend(deployments);
resources.extend(jobs);
// resources.extend(replicasets);
resources.extend(replicasets);
resources.extend(statefulsets);

Ok(resources)
Expand Down
5 changes: 5 additions & 0 deletions examples/test-mixed_v1.24_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ When upgrading the control plane, Amazon EKS performs standard infrastructure an
|----|---------|-------------|-------------|----------|
| ❌ | bad-dpl | deployment | Deployment | 1 |
| ❌ | coredns | kube-system | Deployment | 2 |
| ❌ | bad-rs | replicaset | ReplicaSet | 1 |
| ❌ | bad-ss | statefulset | StatefulSet | 1 |


Expand All @@ -223,6 +224,7 @@ When upgrading the control plane, Amazon EKS performs standard infrastructure an
|----|---------|-------------|-------------|---------|
| ⚠️ | bad-dpl | deployment | Deployment | 0 |
| ⚠️ | coredns | kube-system | Deployment | 0 |
| ⚠️ | bad-rs | replicaset | ReplicaSet | 0 |
| ❌ | bad-ss | statefulset | StatefulSet | 0 |


Expand All @@ -233,13 +235,15 @@ When upgrading the control plane, Amazon EKS performs standard infrastructure an
| | NAME | NAMESPACE | KIND | ANTIAFFINITY | TOPOLOGYSPREADCONSTRAINTS |
|----|---------|-------------|-------------|--------------|---------------------------|
| ❌ | bad-dpl | deployment | Deployment | false | false |
| ❌ | bad-rs | replicaset | ReplicaSet | false | false |
| ❌ | bad-ss | statefulset | StatefulSet | false | false |


#### Check [[K8S006]](https://clowdhaus.github.io/eksup/process/checks/#k8s006)
| | NAME | NAMESPACE | KIND | READINESS PROBE |
|----|---------|-------------|-------------|-----------------|
| ❌ | bad-dpl | deployment | Deployment | false |
| ❌ | bad-rs | replicaset | ReplicaSet | false |
| ❌ | bad-ss | statefulset | StatefulSet | false |


Expand All @@ -257,6 +261,7 @@ When upgrading the control plane, Amazon EKS performs standard infrastructure an
| ❌ | aws-node | kube-system | DaemonSet | true |
| ❌ | bad-dpl | deployment | Deployment | true |
| ❌ | bad-job | job | Job | true |
| ❌ | bad-rs | replicaset | ReplicaSet | true |
| ❌ | bad-ss | statefulset | StatefulSet | true |


Expand Down