Closed vaspahomov closed 9 months ago
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale
because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh
will mark this issue as not stale.
/fresh we use IPAM to get a cidrblock and need to split that cidrblock into subnets, how do you do this in crossplane?
This Composition Function should help - https://github.com/upbound/function-cidr
I think that will do exactly what we want. So I'm attempting to use it now but I'm getting an error attempting to use the function: 0s Warning ComposeResources kcv/crossplane-wt-5zcml cannot compose resources: pipeline step "cidr-block" returned a fatal result: invalid Function input: parameters: Required value: cidrFunc is required
looking at the examples I'm attempting to put this into a step by itself:
- step: cidr-block
functionRef:
name: upbound-function-cidr
input:
apiVersion: platform.upbound.io/v1alpha1
kind: XCIDR
metadata:
name: cidr-subnet
spec:
parameters:
cidrFunc: cidrsubnet
cidrBlock: 123.123.123.0/24
newBits:
- 8
netNum: 3
output: status.atFunction.cidr.subnet-a
Is this not how to use it?
An example composition is here: https://github.com/upbound/function-cidr/blob/main/apis/composition.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xcidrs.platform.upbound.io
spec:
compositeTypeRef:
apiVersion: platform.upbound.io/v1alpha1
kind: XCIDR
mode: Pipeline
pipeline:
- step: cidr
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: spec.parameters.cidrFunc
prefixField: spec.parameters.cidrBlock
newBitsField: spec.parameters.newBits
netNumItemsField: spec.parameters.azs
hostNumField: spec.parameters.hostNum
offsetField: spec.parameters.offset
outputField: spec.parameters.output
ok, so this worked about the way I expected and I'm feeling good about that:
- step: cidr-block
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: cidrsubnets
prefix: "123.123.123.0/24"
newBits:
- 2
- 2
- 2
- 2
outputField: status.subnets
to which I can now see in my Claim:
status:
subnets:
- 123.123.123.0/26
- 123.123.123.64/26
- 123.123.123.128/26
- 123.123.123.192/26
vpcCidr: 123.123.123.0/24
So success!
Next, I'd like to take the output of the vpc creation(from IPAM) which I've put into status.vpcCidr and have that feed into the prefix. How would I do that?
ok so I thought that if I left out the prefix field and attempted to patch it I'd be able to put in the prefix from the vpcCidr. So something like this:
spec:
pipeline:
- step: cidr-block
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: cidrsubnets
newBits:
- 2
- 2
- 2
- 2
outputField: status.subnets
patches:
- fromFieldPath: status.vpcCidr
toFieldPath: input.prefix
type: FromCompositeFieldPath
this doesn't work and gives me the following: 'cannot compose resources: pipeline step "cidr-block" returned a fatal result: invalid Function input: parameters: Required value: either prefix or prefixfield function input is required'
So any ideas how this is accomplished?
I joined the slack channel, and found this: https://github.com/upbound/function-cidr/issues/32 which convinces me that what I'm looking for isn't there yet.
Hi!
There is useful terraform function cidrsubnet Can we implement it in provider-aws to make easier subnet cidr specification?
What problem are you facing?
User story: AWS can provide autogenerated IPv6 cidr for VPC. (I've made PR #881 with AmazonProvidedIpv6CIDRBlock option support.) And for now there are no autogeneration support for subnet cidrs.
How could Crossplane help solve your problem?
Support function that fill 'newbits' in provided ipv6 prefix.
ipv6CIDR
spec block example