|
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,114 @@ 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 `import example.pythonic.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 | + def anything(): |
| 322 | + return 'something' |
| 323 | +``` |
| 324 | +Then, in your Composition: |
| 325 | +```yaml |
| 326 | + ... |
| 327 | + - step: pythonic |
| 328 | + functionRef: |
| 329 | + name: function-pythonic |
| 330 | + input: |
| 331 | + apiVersion: pythonic.fn.fortra.com/v1alpha1 |
| 332 | + kind: Composite |
| 333 | + composite: | |
| 334 | + from example.pythonic import features |
| 335 | + class Composite(BaseComposite): |
| 336 | + def compose(self): |
| 337 | + anything = features.anything() |
| 338 | +``` |
| 339 | +This requires enabling the the packages support using the `--packages` command |
| 340 | +line option in the DeploymentRuntimeConfig and configuring the required |
| 341 | +Kubernetes RBAC permissions. For example: |
| 342 | +```yaml |
| 343 | +apiVersion: pkg.crossplane.io/v1 |
| 344 | +kind: Function |
| 345 | +metadata: |
| 346 | + name: function-pythonic |
| 347 | +spec: |
| 348 | + package: ghcr.io/fortra/function-pythonic:v0.0.6 |
| 349 | + runtimeConfigRef: |
| 350 | + name: function-pythonic |
| 351 | +--- |
| 352 | +apiVersion: pkg.crossplane.io/v1beta1 |
| 353 | +kind: DeploymentRuntimeConfig |
| 354 | +metadata: |
| 355 | + name: function-pythonic |
| 356 | +spec: |
| 357 | + deploymentTemplate: |
| 358 | + spec: |
| 359 | + selector: {} |
| 360 | + template: |
| 361 | + spec: |
| 362 | + containers: |
| 363 | + - name: package-runtime |
| 364 | + args: |
| 365 | + - --debug |
| 366 | + - --packages |
| 367 | + serviceAccountName: function-pythonic |
| 368 | + serviceAccountTemplate: |
| 369 | + metadata: |
| 370 | + name: function-pythonic |
| 371 | +--- |
| 372 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 373 | +kind: ClusterRole |
| 374 | +metadata: |
| 375 | + name: function-pythonic |
| 376 | +rules: |
| 377 | +- apiGroups: |
| 378 | + - '' |
| 379 | + resources: |
| 380 | + - events |
| 381 | + verbs: |
| 382 | + - create |
| 383 | +- apiGroups: |
| 384 | + - '' |
| 385 | + resources: |
| 386 | + - configmaps |
| 387 | + - secrets |
| 388 | + verbs: |
| 389 | + - list |
| 390 | + - watch |
| 391 | + - patch |
| 392 | +--- |
| 393 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 394 | +kind: ClusterRoleBinding |
| 395 | +metadata: |
| 396 | + name: function-pythonic |
| 397 | +roleRef: |
| 398 | + apiGroup: rbac.authorization.k8s.io |
| 399 | + kind: ClusterRole |
| 400 | + name: function-pythonic |
| 401 | +subjects: |
| 402 | +- kind: ServiceAccount |
| 403 | + namespace: crossplane-system |
| 404 | + name: function-pythonic |
| 405 | +``` |
| 406 | +When enabled, labeled ConfigMaps and Secrets are obtained cluster wide, |
| 407 | +requiring the above ClusterRole permissions. The `--packages-name` command |
| 408 | +line option will restrict to only using the supplied namespaces. Per namespace |
| 409 | +RBAC permissions are then required. |
| 410 | + |
| 411 | +## Filing System Packages |
301 | 412 |
|
302 | 413 | Composition Composite implementations can be coded in a stand alone python files |
303 | 414 | by configuring the function-pythonic deployment with the code mounted into |
|
0 commit comments