ResourceQuota support for utils/kubernetes (#2040)

Co-authored-by: chris <chris@Profanity.local>
Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Prawn
2020-10-15 05:34:01 +13:00
committed by GitHub
parent c49fef49b8
commit 04726dbea5
2 changed files with 51 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ var templates = map[string]string{
"serviceaccount": serviceAccountTmpl,
"networkpolicies": networkPolicyTmpl,
"networkpolicy": networkPolicyTmpl,
"resourcequota": resourceQuotaTmpl,
}
var deploymentTmpl = `
@@ -269,3 +270,45 @@ spec:
{{- end }}
{{- end }}
`
var resourceQuotaTmpl = `
apiVersion: v1
kind: ResourceQuota
metadata:
name: "{{ .Metadata.Name }}"
namespace: "{{ .Metadata.Namespace }}"
labels:
{{- with .Metadata.Labels }}
{{- range $key, $value := . }}
{{ $key }}: "{{ $value }}"
{{- end }}
{{- end }}
spec:
hard:
{{- if .Limits }}
{{- with .Limits }}
{{- if .Memory }}
limits.memory: {{ .Memory }}
{{- end }}
{{- if .CPU }}
limits.cpu: {{ .CPU }}
{{- end }}
{{- if .EphemeralStorage }}
limits.ephemeral-storage: {{ .EphemeralStorage }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Requests }}
{{- with .Requests }}
{{- if .Memory }}
requests.memory: {{ .Memory }}
{{- end }}
{{- if .CPU }}
requests.cpu: {{ .CPU }}
{{- end }}
{{- if .EphemeralStorage }}
requests.ephemeral-storage: {{ .EphemeralStorage }}
{{- end }}
{{- end }}
{{- end }}
`

View File

@@ -268,8 +268,15 @@ type VolumeMount struct {
MountPath string `json:"mountPath"`
}
// NetworkPolicy is a Kubernetes Namespace
// NetworkPolicy defines label-based filtering for network ingress
type NetworkPolicy struct {
AllowedLabels map[string]string `json:"allowedLabels,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
}
// ResourceQuota defines resource limits for a namespace
type ResourceQuota struct {
Requests *ResourceLimits `json:"requests,omitempty"`
Limits *ResourceLimits `json:"limits,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
}