|
35 | 35 | vpc.spec.forProvider.cidrBlock = self.spec.cidr |
36 | 36 | self.status.vpcId = vpc.status.atProvider.vpcId |
37 | 37 | ``` |
| 38 | +
|
38 | 39 | In addtion to an inline script, the python implementation can be specified |
39 | | -as the complete path to a python class. See [Filing system Composites](#filing-system-composites). |
| 40 | +as the complete path to a python class. Python packages can be deployed using |
| 41 | +ConfigMaps or Secrets enabling the use of your IDE of choice for writting |
| 42 | +the code. See [ConfigMap and Secret Packages](#configmap-and-secret-packages) |
| 43 | +and [Filing System Packages](#filing-system-packages). |
40 | 44 |
|
41 | 45 | ## Examples |
42 | 46 |
|
@@ -297,7 +301,98 @@ spec: |
297 | 301 | self.status.composite = 'Hello, World!' |
298 | 302 | ``` |
299 | 303 |
|
300 | | -## Filing system Composites |
| 304 | +## ConfigMap and Secret Packages |
| 305 | + |
| 306 | +ConfigMap and Secret based python packages are enable using the `--packages` |
| 307 | +and `--packages-namespace` command line options. ConfigMaps and Secrets |
| 308 | +with the label `function-pythonic.package` will be incorporated in the python |
| 309 | +path at the location configured in the label value. For example, the following |
| 310 | +ConfigMap will enable python to use `from example.pythonic import features` |
| 311 | +```yaml |
| 312 | +apiVersion: v1 |
| 313 | +kind: ConfigMap |
| 314 | +metadata: |
| 315 | + namespace: crossplane-system |
| 316 | + name: example-pythonic |
| 317 | + labels: |
| 318 | + function-pythonic.package: example.pythonic |
| 319 | +data: |
| 320 | + features.py: | |
| 321 | + # this is the features python module |
| 322 | +``` |
| 323 | +This requires enabling the the packages support using the `--packages` command |
| 324 | +line option in the DeploymentRuntimeConfig and configuring the required |
| 325 | +Kubernetes RBAC permissions. For example: |
| 326 | +```yaml |
| 327 | +apiVersion: pkg.crossplane.io/v1 |
| 328 | +kind: Function |
| 329 | +metadata: |
| 330 | + name: function-pythonic |
| 331 | +spec: |
| 332 | + package: ghcr.io/fortra/function-pythonic:v0.0.6 |
| 333 | + runtimeConfigRef: |
| 334 | + name: function-pythonic |
| 335 | +--- |
| 336 | +apiVersion: pkg.crossplane.io/v1beta1 |
| 337 | +kind: DeploymentRuntimeConfig |
| 338 | +metadata: |
| 339 | + name: function-pythonic |
| 340 | +spec: |
| 341 | + deploymentTemplate: |
| 342 | + spec: |
| 343 | + selector: {} |
| 344 | + template: |
| 345 | + spec: |
| 346 | + containers: |
| 347 | + - name: package-runtime |
| 348 | + args: |
| 349 | + - --debug |
| 350 | + - --packages |
| 351 | + serviceAccountName: function-pythonic |
| 352 | + serviceAccountTemplate: |
| 353 | + metadata: |
| 354 | + name: function-pythonic |
| 355 | +--- |
| 356 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 357 | +kind: ClusterRole |
| 358 | +metadata: |
| 359 | + name: function-pythonic |
| 360 | +rules: |
| 361 | +- apiGroups: |
| 362 | + - '' |
| 363 | + resources: |
| 364 | + - events |
| 365 | + verbs: |
| 366 | + - create |
| 367 | +- apiGroups: |
| 368 | + - '' |
| 369 | + resources: |
| 370 | + - configmaps |
| 371 | + - secrets |
| 372 | + verbs: |
| 373 | + - list |
| 374 | + - watch |
| 375 | + - patch |
| 376 | +--- |
| 377 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 378 | +kind: ClusterRoleBinding |
| 379 | +metadata: |
| 380 | + name: function-pythonic |
| 381 | +roleRef: |
| 382 | + apiGroup: rbac.authorization.k8s.io |
| 383 | + kind: ClusterRole |
| 384 | + name: function-pythonic |
| 385 | +subjects: |
| 386 | +- kind: ServiceAccount |
| 387 | + namespace: crossplane-system |
| 388 | + name: function-pythonic |
| 389 | +``` |
| 390 | +When enabled, labeled ConfigMaps and Secrets are obtained from cluster wide, |
| 391 | +requiring the above ClusterRole permissions. The `--packages-name` command |
| 392 | +line option will restrict to only using the supplied namespaces. Per namespace |
| 393 | +RBAC permissions are then required. |
| 394 | + |
| 395 | +## Filing System Packages |
301 | 396 |
|
302 | 397 | Composition Composite implementations can be coded in a stand alone python files |
303 | 398 | by configuring the function-pythonic deployment with the code mounted into |
|
0 commit comments