Skip to content
Open
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't change the Unreleased, it will be update by CI

## [2.2.3] 2025-05-21

### Added

- [#398](https://github.com/green-code-initiative/creedengo-rules-specifications/pull/398) Add news Kubernetes rule GCI1024

### Changed

- Correction of various typos in rules documentations
Expand Down
6 changes: 5 additions & 1 deletion RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ Some are applicable for different technologies.
- ❓ Rule to analyze for applicability
- 🚫 Non applicable rule

| Rule key | Name | Description | Reference/Validation | Java | Php | JS | Python | Rust | C# | HTML |
| Rule key | Name | Description | Reference/Validation | Docker | Kuberenetes | Ansible| Terrafomr |CloudFormation |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo on Terraform (Terrafomr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add the table after the existing one, to avoid modify the header

|----------|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|-----|----|--------|------|----|------|
| GCI1024 | Liveness and readiness probes shuld be defined | | ❓ | 🚧 | ❓ | ❓ | ❓ |

| Rule key | Name | Description | Reference/Validation | Java | Php | JS | Python | Rust | C# | HTML |
|----------|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|-----|----|--------|------|----|------|
| CRJVM205 | Force usage of FetchType LAZY for collections on JPA entities | | | 🚧 | ❓ | ❓ | ❓ | ❓ | ❓ | 🚫 |
| CRJVM206 | Avoid N+1 selects problem | | | 🚧 | ❓ | ❓ | ❓ | ❓ | ❓ | 🚫 |
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@
</descriptors>
</configuration>
</execution>
<execution>
<id>assembly-kubernetes</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/kubernetes.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
Expand Down
18 changes: 18 additions & 0 deletions src/main/assembly/kubernetes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>kubernetes</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>org/green-code-initiative/rules/kubernetes/*.*</include>
</includes>
<outputDirectory/>
</fileSet>
</fileSets>
</assembly>
16 changes: 16 additions & 0 deletions src/main/rules/GCI1024/GCI1024.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Liveness and liveness detection should be avoided",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5 min"
},
"tags": [
"performance",
"iac",
"eco-design",
"creedengo"
],
"defaultSeverity": "Minor"
}
60 changes: 60 additions & 0 deletions src/main/rules/GCI1024/kubernetes/GCI1024.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
== Why this rule is important ?

The absence of liveness or readiness probes in a Kubernetes deployment can cause undesirable effects:

- Unstable containers that unnecessarily consume CPU/memory resources.
- Unready applications receiving traffic, increasing errors and client-side retries.
- More frequent redeployments or crash-loops.
- Increased carbon footprint due to inefficient use of resources.

Defining these probes ensures that the pod is properly supervised by Kubernetes, limiting wasted resources and promoting a leaner, more stable cluster.

Additional information available on:

* Research articles:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Theses articles do not seems to talk about probe (did not read it entirely)

** https://arxiv.org/html/2504.10702v1[Container-level Energy Observability in Kubernetes Clusters]
** https://arxiv.org/pdf/2503.08641[A Comprehensive Experimentation Framework for Energy-Efficient Design of Cloud-Native Applications]
* Official Kubernetes documentation: https://kubernetes.io/docs/concepts/configuration/liveness-readiness-startup-probes/[Liveness, Readiness, and Startup Probes]

== Non Compliant Code Example



[source,yml]
----
# Liveness et readiness probes absentes
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 2
template:
spec:
containers:
- name: my-app
image: my-image:latest

----

== Compliant Code Example

[source,yml]
----

livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5

readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10


----