Hello SIG,
I've been working in the PR of issue #93267
(
https://github.com/kubernetes/kubernetes/issues/93267) in
https://github.com/kubernetes/kubernetes/pull/94327 and would like
some opinions. First of all, sorry for the long email and please feel
free to put your thoughts, ideas, criticisms and make suggestions. I
know the code isn't actually pretty (yet) and the syntax isn't neither
:) Also once I got your thoughts about this, I can propose the PR to
sig-cli because maybe this command structure might be against some
guideline.
The main problem of this command is that Ingress is a much more
complex object than the other ones. So you can have one to any hosts,
you can have no hosts but backends defined (the catch all ingress),
you can have different Path Prefixes, each for a path that can be
inside a host.
So Tim has "proposed" (in the way of 'this would work') something like:
kubectl create ingress myingress \
--host=
myhost.com --pathtype=prefix --path=/foo
--service-name=foo-svc --service-port=80 \
--host=
yourhost.com --pathtype=prefix --path=/bar
--service-name=bar-svc --service-port=80
1) The first problem starts with a case where a host has multiple
paths. The idea above is something 'positional', so my idea right now
is that the 'main' argument here is the 'path', but for each path you
need to re-declare a host. As an example, a host "
bla.com" with paths
"/foo" and "/bar" would have duplicate declarations:
# host[0] ptype[0] path[0]
svcname[0] svcport[0]
--host=
bla.com --pathtype=prefix --path=/foo --service-name=foo-svc
--service-port=80 \
# host[1] ptype[1] path[1]
svcname[1] svcport[1]
--host=
bla.com --pathtype=prefix --path=/bar --service-name=bar-svc
--service-port=80
Assuming the usage of 'cobra' library, and that I couldn't find any
'grouping' argument, how does this sound to you? Anyone got a better
idea? The validation case in the kubectl command will be "the number
of host arguments must be equal to the number of pathtype arguments
that must be equal to path argument" and so goes on.
The same above is valid as:
kubectl create ingress myingress --host=
myhost.com,
yourhost.com
--pathtype=prefix,prefix --path=/foo,/bar etc etc (Cobra
StringSliceVar being used here). It's not pretty, but it "works"
2) One can have a path without a host declaration. Because every path
needs its host, I'm looking for the "_" (underscore) character as a
wildcard/catchall. Like --host="_" represents no host. The creation of
an ingress with char "_" is forbidden, so does this sounds good,
parsing hosts with a single "_" and turning this into a 'no host rule
spec'?
3) Opposite to other kubectl create commands, and because of historic
Ingress object needs, I'm adding a -a/--annotation flag so users can
provide their annotations. This is not functional yet in the PR, but
is this something that causes a good or a bad feeling?
4) TLS rules suffer the same problem as the ingress rules. One might
have a rule with a single secretName and no hosts, no secretName and
any hosts, and a secretName with multiple hosts.
So here I'm looking for something like
--tls=secretName,
host1.com,
host2.com --tls=_,
host3.com,
host4.com.
Thoughts?
5) I'm considering in this first go backends of type
IngressServiceBackend (for both default-backend and backends inside
ingress rules) and disregarding the v1.TypedLocalObjectReference as a
possible ingress. IMO the command is already "ugly" enough, don't know
how much use cases we would have for this once the command is
available.
Suggestion/opinions are always welcome, and have a nice weekend you all.