Coverage for ocp_resources/ingress_controller.py: 0%

68 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 10:48 +0200

1from typing import Any, Dict, Optional 

2from ocp_resources.resource import NamespacedResource 

3 

4 

5class IngressController(NamespacedResource): 

6 """ 

7 https://docs.openshift.com/container-platform/4.15/rest_api/operator_apis/ingresscontroller-operator-openshift-io-v1.html 

8 """ 

9 

10 api_group = NamespacedResource.ApiGroup.OPERATOR_OPENSHIFT_IO 

11 

12 def __init__( 

13 self, 

14 domain: Optional[str] = "", 

15 replicas: Optional[int] = None, 

16 endpoint_publishing_strategy: Optional[Dict[str, Any]] = None, 

17 default_certificate: Optional[Dict[str, str]] = None, 

18 namespace_selector: Optional[Dict[str, Any]] = None, 

19 node_selector: Optional[Dict[str, Any]] = None, 

20 route_selector: Optional[Dict[str, Any]] = None, 

21 tls_security_profile: Optional[Dict[str, Any]] = None, 

22 logging: Optional[Dict[str, Any]] = None, 

23 route_admission: Optional[Dict[str, Any]] = None, 

24 client_tls: Optional[Dict[str, Any]] = None, 

25 trusted_ca: Optional[Dict[str, Any]] = None, 

26 http_compression: Optional[Dict[str, str]] = None, 

27 http_empty_requests_policy: Optional[str] = "", 

28 http_error_code_pages: Optional[Dict[str, Any]] = None, 

29 http_headers: Optional[Dict[str, Any]] = None, 

30 node_placement: Optional[Dict[str, Any]] = None, 

31 tuning_options: Optional[Dict[str, Any]] = None, 

32 unsupported_config_overrides: Optional[Dict[str, Any]] = None, 

33 **kwargs: Any, 

34 ) -> None: 

35 """ 

36 Args: 

37 domain (str, optional): The domain for the ingress controller. 

38 replicas (int, optional): The number of desired replicas. 

39 endpoint_publishing_strategy (dict, optional): The strategy for publishing endpoints. 

40 Example: { 

41 "type": "LoadBalancerService", 

42 "loadBalancer": { 

43 "scope": "External" 

44 } 

45 } 

46 default_certificate (dict, optional): A reference to a secret containing the default certificate. 

47 Example: { 

48 "name": "default-cert-secret", 

49 "namespace": "openshift-ingress" 

50 } 

51 namespace_selector (dict, optional): A selector to select which namespaces the ingress controller should observe. 

52 Example: { 

53 "matchLabels": { 

54 "app": "myapp" 

55 } 

56 } 

57 node_selector (dict, optional): A selector to select nodes the ingress controller should run on. 

58 Example: { 

59 "matchLabels": { 

60 "node-role.kubernetes.io/worker": "" 

61 } 

62 } 

63 route_selector (dict, optional): A selector to select which routes the ingress controller should observe. 

64 Example: { 

65 "matchLabels": { 

66 "route": "myroute" 

67 } 

68 } 

69 tls_security_profile (dict, optional): Settings for TLS connections. 

70 Example: { 

71 "type": "Intermediate" 

72 } 

73 logging (dict, optional): Parameters for logging. 

74 Example: { 

75 "access": { 

76 "destination": { 

77 "type": "Container", 

78 "name": "access-logs" 

79 } 

80 } 

81 } 

82 route_admission (dict, optional): Policy for handling new route claims. 

83 Example: { 

84 "namespaceOwnership": "InterNamespaceAllowed" 

85 } 

86 client_tls (dict, optional): Client TLS settings, including `clientCA` and `clientCertificatePolicy`. 

87 Example: { 

88 "clientCA": { 

89 "name": "client-ca", 

90 "namespace": "openshift-ingress" 

91 }, 

92 "clientCertificatePolicy": "Required" 

93 } 

94 trusted_ca (dict, optional): TrustedCA data. 

95 Example: { 

96 "name": "trusted-ca", 

97 "namespace": "openshift-config" 

98 } 

99 http_compression (dict, optional): Policy for HTTP traffic compression. 

100 Example: { 

101 "type": "Gzip" 

102 } 

103 http_empty_requests_policy (str, optional): Policy for handling HTTP connections if the connection times out. 

104 http_error_code_pages (dict, optional): Custom error pages. 

105 Example: { 

106 "name": "custom-error-pages", 

107 "namespace": "openshift-config" 

108 } 

109 http_headers (dict, optional): Policy for HTTP headers. 

110 Example: { 

111 "setHeaders": { 

112 "Strict-Transport-Security": "max-age=31536000; includeSubDomains" 

113 } 

114 } 

115 node_placement (dict, optional): Control over the scheduling of the ingress controller. 

116 Example: { 

117 "nodeSelector": { 

118 "matchLabels": { 

119 "kubernetes.io/os": "linux" 

120 } 

121 }, 

122 "tolerations": [ 

123 { 

124 "effect": "NoSchedule", 

125 "operator": "Exists" 

126 } 

127 ] 

128 } 

129 tuning_options (dict, optional): Parameters for adjusting the performance of ingress controller pods. 

130 Example: { 

131 "maxConnections": 10000 

132 } 

133 unsupported_config_overrides (dict, optional): Unsupported configuration options. 

134 Example: { 

135 "customConfig": "value" 

136 } 

137 """ 

138 super().__init__(**kwargs) 

139 self.domain = domain 

140 self.replicas = replicas 

141 self.endpoint_publishing_strategy = endpoint_publishing_strategy 

142 self.default_certificate = default_certificate 

143 self.namespace_selector = namespace_selector 

144 self.node_selector = node_selector 

145 self.route_selector = route_selector 

146 self.tls_security_profile = tls_security_profile 

147 self.logging = logging 

148 self.route_admission = route_admission 

149 self.client_tls = client_tls 

150 self.trusted_ca = trusted_ca 

151 self.http_compression = http_compression 

152 self.http_empty_requests_policy = http_empty_requests_policy 

153 self.http_error_code_pages = http_error_code_pages 

154 self.http_headers = http_headers 

155 self.node_placement = node_placement 

156 self.tuning_options = tuning_options 

157 self.unsupported_config_overrides = unsupported_config_overrides 

158 

159 def to_dict(self) -> None: 

160 super().to_dict() 

161 

162 if not self.kind_dict and not self.yaml_file: 

163 self.res["spec"] = {} 

164 _spec = self.res["spec"] 

165 

166 if self.domain: 

167 _spec["domain"] = self.domain 

168 

169 if self.replicas: 

170 _spec["replicas"] = self.replicas 

171 

172 if self.endpoint_publishing_strategy: 

173 _spec["endpointPublishingStrategy"] = self.endpoint_publishing_strategy 

174 

175 if self.default_certificate: 

176 _spec["defaultCertificate"] = self.default_certificate 

177 

178 if self.namespace_selector: 

179 _spec["namespaceSelector"] = self.namespace_selector 

180 

181 if self.node_selector: 

182 _spec["nodeSelector"] = self.node_selector 

183 

184 if self.route_selector: 

185 _spec["routeSelector"] = self.route_selector 

186 

187 if self.tls_security_profile: 

188 _spec["tlsSecurityProfile"] = self.tls_security_profile 

189 

190 if self.logging: 

191 _spec["logging"] = self.logging 

192 

193 if self.route_admission: 

194 _spec["routeAdmission"] = self.route_admission 

195 

196 if self.client_tls: 

197 _spec["clientTLS"] = self.client_tls 

198 

199 if self.trusted_ca: 

200 _spec["trustedCA"] = self.trusted_ca 

201 

202 if self.http_compression: 

203 _spec["httpCompression"] = self.http_compression 

204 

205 if self.http_empty_requests_policy: 

206 _spec["httpEmptyRequestsPolicy"] = self.http_empty_requests_policy 

207 

208 if self.http_error_code_pages: 

209 _spec["httpErrorCodePages"] = self.http_error_code_pages 

210 

211 if self.http_headers: 

212 _spec["httpHeaders"] = self.http_headers 

213 

214 if self.node_placement: 

215 _spec["nodePlacement"] = self.node_placement 

216 

217 if self.tuning_options: 

218 _spec["tuningOptions"] = self.tuning_options 

219 

220 if self.unsupported_config_overrides: 

221 _spec["unsupportedConfigOverrides"] = self.unsupported_config_overrides