Xe's Kubernetes custom resources
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(within-website-app): grpc support

Signed-off-by: Xe Iaso <me@xeiaso.net>

+37 -18
+1 -6
within-website-app/nginx.yaml
··· 11 11 healthcheck: 12 12 enabled: true 13 13 14 - onion: 15 - enabled: true 16 - proofOfWorkDefense: true 17 - 18 14 ingress: 19 15 enabled: true 20 - host: nginx.ellenjoe.within.lgbt 21 - enableCoreRules: true 16 + host: nginx.limsa-lominsa.within.lgbt
+9 -7
within-website-app/v1/app.go
··· 24 24 25 25 // Our Backend Specification 26 26 type AppSpec struct { 27 - AutoUpdate bool `json:"autoUpdate,omitempty" yaml:"autoUpdate,omitempty"` 28 - Image string `json:"image" yaml:"image"` 29 - LogLevel string `json:"logLevel,omitempty" yaml:"logLevel,omitempty"` 30 - Replicas int32 `json:"replicas,omitempty" yaml:"replicas,omitempty"` 31 - Port int `json:"port,omitempty" yaml:"port,omitempty"` 32 - RunAsRoot bool `json:"runAsRoot,omitempty" yaml:"runAsRoot,omitempty"` 33 - Env []corev1.EnvVar `json:"env,omitempty" yaml:"env,omitempty"` 27 + AutoUpdate bool `json:"autoUpdate,omitempty" yaml:"autoUpdate,omitempty"` 28 + Image string `json:"image" yaml:"image"` 29 + ImagePullSecrets []string `json:"imagePullSecrets" yaml:"imagePullSecrets"` 30 + LogLevel string `json:"logLevel,omitempty" yaml:"logLevel,omitempty"` 31 + Replicas int32 `json:"replicas,omitempty" yaml:"replicas,omitempty"` 32 + Port int `json:"port,omitempty" yaml:"port,omitempty"` 33 + RunAsRoot bool `json:"runAsRoot,omitempty" yaml:"runAsRoot,omitempty"` 34 + Env []corev1.EnvVar `json:"env,omitempty" yaml:"env,omitempty"` 34 35 35 36 // Resources *corev1.ResourceRequirements `json:"resources,omitempty" yaml:"resources,omitempty"` 36 37 ··· 63 64 64 65 type Ingress struct { 65 66 Enabled bool `json:"enabled" yaml:"enabled"` 67 + Kind string `json:"kind" yaml:"kind"` 66 68 Host string `json:"host" yaml:"host"` 67 69 ClusterIssuer string `json:"clusterIssuer,omitempty" yaml:"clusterIssuer,omitempty"` 68 70 ClassName string `json:"className,omitempty" yaml:"className,omitempty"`
+27 -5
within-website-app/v1/flight/main.go
··· 186 186 // } 187 187 // } 188 188 189 + for _, imagePullSecret := range backend.Spec.ImagePullSecrets { 190 + result.Spec.Template.Spec.ImagePullSecrets = append(result.Spec.Template.Spec.ImagePullSecrets, corev1.LocalObjectReference{ 191 + Name: imagePullSecret, 192 + }) 193 + } 194 + 189 195 if backend.Spec.Healthcheck != nil && backend.Spec.Healthcheck.Enabled { 190 196 if backend.Spec.Healthcheck.Port == 0 { 191 197 backend.Spec.Healthcheck.Port = backend.Spec.Port ··· 264 270 } 265 271 266 272 func createService(backend v1.App) *corev1.Service { 267 - return &corev1.Service{ 273 + result := &corev1.Service{ 268 274 TypeMeta: metav1.TypeMeta{ 269 275 APIVersion: corev1.SchemeGroupVersion.Identifier(), 270 276 Kind: "Service", 271 277 }, 272 278 ObjectMeta: metav1.ObjectMeta{ 273 - Name: backend.Name, 274 - Namespace: backend.Namespace, 275 - Labels: backend.Labels, 279 + Name: backend.Name, 280 + Namespace: backend.Namespace, 281 + Labels: backend.Labels, 282 + Annotations: map[string]string{}, 276 283 }, 277 284 Spec: corev1.ServiceSpec{ 278 285 Selector: selector(backend), ··· 287 294 }, 288 295 }, 289 296 } 297 + 298 + if backend.Spec.Ingress != nil && backend.Spec.Ingress.Enabled && backend.Spec.Ingress.Kind == "grpc" { 299 + maps.Copy(result.Annotations, map[string]string{ 300 + "traefik.ingress.kubernetes.io/service.serversscheme": "h2c", 301 + }) 302 + } 303 + 304 + return result 290 305 } 291 306 292 307 func createIngress(app v1.App) (*networkingv1.Ingress, error) { 293 308 annotations := map[string]string{ 294 - "cert-manager.io/cluster-issuer": app.Spec.Ingress.ClusterIssuer, 309 + "cert-manager.io/cluster-issuer": app.Spec.Ingress.ClusterIssuer, 310 + "nginx.ingress.kubernetes.io/ssl-redirect": "true", 295 311 } 296 312 maps.Copy(annotations, app.Spec.Ingress.Annotations) 297 313 result := &networkingv1.Ingress{ ··· 343 359 result.Annotations["nginx.ingress.kubernetes.io/enable-owasp-core-rules"] = "true" 344 360 result.Annotations["nginx.ingress.kubernetes.io/enable-modsecurity"] = "true" 345 361 result.Annotations["nginx.ingress.kubernetes.io/modsecurity-transaction-id"] = "$request_id" 362 + } 363 + 364 + if app.Spec.Ingress.Kind == "grpc" { 365 + maps.Copy(result.Annotations, map[string]string{ 366 + "nginx.ingress.kubernetes.io/backend-protocol": "GRPC", 367 + }) 346 368 } 347 369 348 370 var configSnippet strings.Builder