github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/latest/apigateway.go (about) 1 package latest 2 3 import ( 4 "github.com/caos/orbos/pkg/kubernetes/k8s" 5 "github.com/caos/orbos/pkg/secret" 6 ) 7 8 type APIGateway struct { 9 //Flag if tool should be deployed 10 //@default: false 11 Deploy bool `json:"deploy" yaml:"deploy"` 12 //Number of replicas used for deployment 13 //@default: 1 14 ReplicaCount int `json:"replicaCount,omitempty" yaml:"replicaCount,omitempty"` 15 //Pod scheduling constrains 16 Affinity *k8s.Affinity `json:"affinity,omitempty" yaml:"affinity,omitempty"` 17 //Service definition for ambassador 18 Service *AmbassadorService `json:"service,omitempty" yaml:"service,omitempty"` 19 //Activate the dev portal mapping 20 ActivateDevPortal bool `json:"activateDevPortal,omitempty" yaml:"activateDevPortal,omitempty"` 21 //NodeSelector for deployment 22 NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"` 23 //Tolerations to run ambassador on nodes 24 Tolerations k8s.Tolerations `json:"tolerations,omitempty" yaml:"tolerations,omitempty"` 25 //Resource requirements 26 Resources *k8s.Resources `json:"resources,omitempty" yaml:"resources,omitempty"` 27 //Caching options 28 Caching *Caching `json:"caching,omitempty" yaml:"caching,omitempty"` 29 //Enable gRPC Web 30 //@default: false 31 GRPCWeb bool `json:"grpcWeb,omitempty" yaml:"grpcWeb,omitempty"` 32 //Enable proxy protocol 33 //@default: true 34 ProxyProtocol *bool `json:"proxyProtocol,omitempty" yaml:"proxyProtocol,omitempty"` 35 //Overwrite used image 36 OverwriteImage string `json:"overwriteImage,omitempty" yaml:"overwriteImage,omitempty"` 37 //Overwrite used image version 38 OverwriteVersion string `json:"overwriteVersion,omitempty" yaml:"overwriteVersion,omitempty"` 39 //License-key to use for Ambassador 40 LicenceKey *secret.Secret `json:"licenceKey,omitempty" yaml:"licenceKey,omitempty"` 41 //License-key to use for Ambassador 42 ExistingLicenceKey *secret.Existing `json:"existingLicenceKey,omitempty" yaml:"existingLicenceKey,omitempty"` 43 } 44 45 func (a *APIGateway) IsZero() bool { 46 if !a.Deploy && 47 a.ReplicaCount == 0 && 48 a.Affinity == nil && 49 a.Service == nil && 50 !a.ActivateDevPortal && 51 a.NodeSelector == nil && 52 a.Tolerations == nil && 53 a.Resources == nil && 54 a.Caching == nil && 55 !a.GRPCWeb && 56 a.ProxyProtocol == nil && 57 a.OverwriteVersion == "" && 58 (a.LicenceKey == nil || a.LicenceKey.IsZero()) && 59 a.ExistingLicenceKey == nil { 60 return true 61 } 62 63 return false 64 } 65 66 func (a *APIGateway) InitSecrets() { 67 if a.LicenceKey == nil { 68 a.LicenceKey = &secret.Secret{} 69 a.ExistingLicenceKey = &secret.Existing{} 70 } 71 } 72 73 type Caching struct { 74 //Enable specifies, whether a redis instance should be deployed or not 75 Enable bool `json:"enable" yaml:"enable"` 76 //Resource requirements 77 Resources *k8s.Resources `json:"resources,omitempty" yaml:"resources,omitempty"` 78 } 79 80 type AmbassadorService struct { 81 //Kubernetes service type 82 Type string `json:"type,omitempty" yaml:"type,omitempty"` 83 //IP when service is a loadbalancer with a fixed IP 84 LoadBalancerIP string `json:"loadBalancerIP,omitempty" yaml:"loadBalancerIP,omitempty"` 85 //Port definitions for the service 86 Ports []*Port `json:"ports,omitempty" yaml:"ports,omitempty"` 87 } 88 89 type Port struct { 90 //Name of the Port 91 Name string `json:"name,omitempty" yaml:"name,omitempty"` 92 //Port number 93 Port uint16 `json:"port,omitempty" yaml:"port,omitempty"` 94 //Targetport in-cluster 95 TargetPort uint16 `json:"targetPort,omitempty" yaml:"targetPort,omitempty"` 96 //Used port on node 97 NodePort uint16 `json:"nodePort,omitempty" yaml:"nodePort,omitempty"` 98 }