Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c850018ca | |||
|
3623ede85d
|
|||
|
a7ce0a5b5d
|
|||
| 6b70891bb0 | |||
|
4452c7e136
|
@@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [1.2.1] - 2025-10-01
|
||||||
|
|
||||||
|
### 🚜 Refactor
|
||||||
|
|
||||||
|
- Simplify namespace exclusion logic
|
||||||
|
|
||||||
|
### 📚 Documentation
|
||||||
|
|
||||||
|
- *(deploy)* Add delete permission for limitranges resource
|
||||||
|
|
||||||
|
## [1.2.0] - 2025-10-01
|
||||||
|
|
||||||
|
### 🚀 Features
|
||||||
|
|
||||||
|
- Improve LimitRange management in namespaces
|
||||||
|
|
||||||
## [1.1.14] - 2025-09-10
|
## [1.1.14] - 2025-09-10
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
### 🐛 Bug Fixes
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ rules:
|
|||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["limitranges"]
|
resources: ["limitranges"]
|
||||||
verbs: ["list","create"]
|
verbs: ["list","create"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["limitranges"]
|
||||||
|
verbs: ["delete"]
|
||||||
|
resourceNames: ["extreme-request-defaults"]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -61,18 +62,26 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, ns := range namespaces.Items {
|
for _, ns := range namespaces.Items {
|
||||||
|
log.Printf("Checking for LimitRange named extreme-request-defaults in namespace '%v'\n", ns.Name)
|
||||||
|
limitRanges, err := clientset.CoreV1().LimitRanges(ns.Name).List(ctx, metav1.ListOptions{FieldSelector: "metadata.name=extreme-request-defaults"})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Unable to list LimitRanges in namespace '%v': Error: %v\n", ns.Name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !nsExcluded(ns.Name, excludedNS) {
|
if !nsExcluded(ns.Name, excludedNS) {
|
||||||
log.Printf("Checking for LimitRange named extreme-request-defaults in namespace '%v'\n", ns.Name)
|
if len(limitRanges.Items) == 0 {
|
||||||
if limitRanges, err := clientset.CoreV1().LimitRanges(ns.Name).List(ctx, metav1.ListOptions{FieldSelector: "metadata.name=extreme-request-defaults"}); err != nil {
|
log.Printf("Trying to create LimitRange\n")
|
||||||
panic(err)
|
if _, err := clientset.CoreV1().LimitRanges(ns.Name).Create(ctx, &limitRange, metav1.CreateOptions{}); err != nil {
|
||||||
} else {
|
log.Printf("Unable to create LimitRange in namespace '%v': Error: %v\n", ns.Name, err)
|
||||||
if len(limitRanges.Items) == 0 {
|
} else {
|
||||||
log.Printf("Trying to create LimitRange\n")
|
log.Printf("LimitRange extreme-request-defaults created in namespace '%v'\n", ns.Name)
|
||||||
if _, err := clientset.CoreV1().LimitRanges(ns.Name).Create(ctx, &limitRange, metav1.CreateOptions{}); err != nil {
|
}
|
||||||
log.Printf("Unable to create LimitRange in namespace '%v': Error: %v\n", ns.Name, err)
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("LimitRange extreme-request-defaults created in namespace '%v'\n", ns.Name)
|
if len(limitRanges.Items) > 0 {
|
||||||
}
|
log.Printf("Trying to delete LimitRange\n")
|
||||||
|
if err := clientset.CoreV1().LimitRanges(ns.Name).Delete(ctx, "extreme-request-defaults", metav1.DeleteOptions{}); err != nil {
|
||||||
|
log.Printf("Unable to delete LimitRange in namespace '%v': Error: %v\n", ns.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,12 +92,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func nsExcluded(name string, excludedNS []string) bool {
|
func nsExcluded(name string, excludedNS []string) bool {
|
||||||
for _, ns := range excludedNS {
|
return slices.Contains(excludedNS, name) || slices.Contains(excludedNS, "*")
|
||||||
if name == ns {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseArgs() args {
|
func parseArgs() args {
|
||||||
|
|||||||
Reference in New Issue
Block a user