We are going to design a policy bundle for a service mesh (like Istio) that includes:
mTLS (mutual TLS) for authentication and encryption.
Retries to handle transient failures.
Timeouts to prevent long waits and resource exhaustion.
Configuration promotion gates: this likely means we want to have a way to phase in these policies, perhaps by environment (e.g., staging, production) or by a percentage of traffic.
We'll assume we are using a service mesh that supports a policy bundle definition (like a YAML file that can be applied to the mesh).
Steps:
Define an mTLS policy that sets the mesh to use mTLS by default (or per namespace/service) and includes a certificate management setup.
Define retry policies for both client and server sides (typically on the client side, but sometimes server can also trigger retries?).
Define timeout policies for requests.
Define promotion gates: we might use labels or annotations to target specific services or use a gateway to apply policies conditionally.
However, note that in Istio, for example, we have different resources for these:
For mTLS: PeerAuthentication and AuthenticationPolicy (though in newer versions, AuthenticationPolicy is deprecated in favor of PeerAuthentication and RequestAuthentication). But for mTLS at the mesh level, we can set a PeerAuthentication policy at the mesh level (or per namespace) to enforce STRICT mTLS.
For retries: we define a DestinationRule (or sometimes in VirtualService) but typically DestinationRule for outlier detection and connection pool settings, and VirtualService for HTTP retry policies.
For timeouts: we set in VirtualService (for HTTP) and in DestinationRule (for TCP) or in the client-side configuration.
For promotion gates: we might use a combination of labels and apply the policy only to services with a certain label. Alternatively, we can use a gateway to split traffic and apply policies to specific subsets.
However, note that the requirement says "configuration promotion gates", which might mean we want to roll out these policies gradually. We can achieve that by:
a) Using canary deployments and gradually increasing the percentage of traffic that goes through the services that have the policies applied. But the policies themselves are applied to the services, not to the traffic. So we might need to have two versions of the service (with and without the policy) and then gradually shift traffic.
b) Alternatively, we can use a policy that applies conditionally based on source labels or namespaces. But that might not be a gradual promotion.
c) Another idea: use a sidecar configuration that includes the policies and then gradually roll out the sidecar injection.
Given the complexity, we might break the policy bundle into multiple YAML files and use a tool like Helm or Kustomize to manage the promotion.
But the problem asks for a single policy bundle? Or a bundle that can be promoted in stages?
Let's reinterpret: we are to design a policy bundle that includes these policies and has built-in gates for promotion. This might mean that the policy bundle itself has conditions that determine when it is active.
In Istio, we can use AuthorizationPolicy with conditions? Or use PeerAuthentication with a mtls mode that is conditional? Actually, PeerAuthentication doesn't have conditions. It's applied to workloads based on labels.
So we can define the policies for a set of workloads that have a specific label, and then gradually add that label to our workloads? That would be a form of promotion.
Alternatively, we can use a gateway and virtual services to route a percentage of traffic to a set of services that have the policies, and the rest to services without. But then the policies are on the services, not on the traffic.
Let's think of a different approach: we can have two sets of policies (with and without) and then use a gateway to split traffic and apply the policies to the subset that goes through a specific gateway? But policies are applied to the workload, not the traffic path.
Actually, in Istio, retries and timeouts are set in the VirtualService and DestinationRule, which are traffic routing rules. So we can have two VirtualServices: one with retries and timeouts and one without, and then split traffic between them. But that would require duplicating the destination.
Alternatively, we can use a single VirtualService and use a subset in DestinationRule that has different connection pool settings (for retries and timeouts) and then route to that subset conditionally? But conditionally based on what? We can use headers or source labels to split traffic.
However, note that the requirement is for a policy bundle that captures these settings and has promotion gates. So maybe we are to design a bundle that can be applied conditionally.
Since the question is open-ended, let's design a bundle that includes:
A PeerAuthentication policy that enforces mTLS for services with a specific label (say mesh-promotion: enabled). We can also set the mesh-level default to PERMISSIVE and then enforce only on labeled services? Or set the mesh to STRICT and then use an exception for services without the label? Actually, PeerAuthentication works by accumulating rules and the most specific rule (by labels) wins. So we can set:
Mesh-level: PERMISSIVE (so that services without the label can still communicate without mTLS)
Namespace-level (optional): we can set a namespace to PERMISSIVE or STRICT.
Then, for services we want to enforce mTLS, we label them and create a PeerAuthentication that selects them and sets mode: STRICT.
For retries and timeouts: we can define a DestinationRule and VirtualService that apply to the same set of labeled services? But note that VirtualService and DestinationRule are for routing and destination settings. They are applied to the host (service) and can be overridden by subset. We can create a DestinationRule that defines a subset for the services that have the label and set the connection pool (for timeouts and maybe for retries? Actually, retries are in VirtualService and connection pool is in DestinationRule). But we want to apply the same retry and timeout settings to the services that have the label.
However, note that the retry policy is in the VirtualService of the client (the source of the request). So we need to configure the client's VirtualService to retry when calling the services with the label? That would require that the client knows which services are labeled? That's not straightforward.
Alternatively, we can use a Sidecar policy to configure the client side? In Istio, we can set a Sidecar that includes egress hosts and then set the retry and timeout for those egress hosts? But again, we are applying on the client side.
Given the complexity, maybe we are only concerned with server-side timeouts and client-side retries for outgoing calls? But the policy bundle should capture both?
Let's re-read: "mTLS, retries, and timeouts". Typically:
mTLS is for both client and server (authentication and encryption).
Retries are usually configured on the client side (the service that is making the call) to retry on failure.
Timeouts can be set on both client (to not wait too long) and server (to limit the time a request takes).
In Istio:
mTLS: PeerAuthentication (server side) and RequestAuthentication (for JWT, etc.) but for mTLS we use PeerAuthentication.
Retries: set in the client's VirtualService (for HTTP) or DestinationRule (for TCP) in the outlierDetection? Actually, for HTTP retries, we use retries in the VirtualService route.
Timeouts: set in the VirtualService route (for HTTP) and in DestinationRule for TCP.
# Apply bundle to staging first
kubectl apply -f policy-bundles/staging.yaml
# Promote to canary (5%)
kubectl annotate ns production policy.example.com/phase=canary-5%
# Full rollout
kubectl patch policybundle production-services \
-p '{"spec":{"promotion":{"currentStage":"full-rollout"}}}'
This design provides:
Safety: Gates prevent bad rollouts
Visibility: Clear stage progression
Automation: GitOps-driven with validation
Flexibility: Works with any service mesh supporting these standards
Rollback: Simple via Git revert or stage downgrade
The bundle can be extended with additional policies (rate limiting, fault injection, etc.) following the same pattern.
So the policies are applied at the client side for retries and timeouts? Actually, the VirtualService that defines the route to a destination also can set the timeout and retry for that route. And that VirtualService is applied on the client's side? Wait, no: VirtualService is a configuration for the sidecar proxy (or gateway) that defines how to route requests. So if we have a service A that calls service B, then the VirtualService that routes to B is read by the sidecar of A? Not exactly. In Istio, the VirtualService is associated with the destination host (the service being called) and is used by the sidecar of the source (the caller) to determine how to route to the destination. So the retry and timeout settings in the VirtualService for host B will be applied when any service calls B, provided they are in the same mesh and the sidecar of the caller reads that VirtualService.
But note: the VirtualService is not applied to the server (B) but to the client (A). So the retry and timeout are client-side configurations.
So to have retries and timeouts for calls to a service, we need to define a VirtualService for that service. And that VirtualService will be used by every caller in the mesh (unless they have their own VirtualService that overrides?).
However, we want to apply these settings only to services that have the label? But the VirtualService selects a host (by name) and not by the labels of the host. So we cannot conditionally apply a VirtualService based on the labels of the destination service? Actually, the VirtualService applies to a host (or hosts) by name. So if we want to apply a policy only to services with a label, we would have to know the names of those services and list them in the VirtualService? That doesn't scale.
Alternatively, we can use a subset in DestinationRule? The DestinationRule defines subsets for a host, and then the VirtualService can route to a subset. But again, we are tying to host names.
Given that, maybe the promotion gate for retries and timeouts is not straightforward.
Let's change the design: instead of trying to conditionally apply the policies based on the destination's labels, we can apply them to all services in a namespace or mesh? But then we lose the ability to promote gradually.
Another idea: use a Sidecar configuration that sets the outbound traffic policy for a set of workloads (the clients that are labeled). But then we have to label the clients, not the servers.
Given the complexity, perhaps the intended design is:
mTLS: apply to the services that are labeled (server side).
Retries and timeouts: apply to the clients that are labeled? But note that the client might be calling multiple services. We want to apply retries and timeouts only when calling the services that are also labeled? That would require the client to know which destinations are labeled.
This is getting too complicated.
Maybe the requirement is to have a bundle that includes these policies and then we can promote the bundle by gradually applying the bundle to more services (by adding the label that selects the policies). But for retries and timeouts, we need to define the policies on the client side, so we would label the clients.
Alternatively, we can design the bundle to be applied at the namespace level? Then we can promote by namespace.
Let's assume we are going to apply the policies at the namespace level. We can have:
A PeerAuthentication that applies to the entire namespace (or mesh) and enforces mTLS.
A DestinationRule and VirtualService that apply to the services in the namespace? But again, VirtualService is by host.
Actually, we can create a VirtualService that matches all hosts in the namespace? Not directly. We have to list the hosts.
Given the constraints, maybe we design the bundle as:
For mTLS:
PeerAuthentication that applies to the namespace (or mesh) and sets mode: STRICT.
For retries and timeouts:
We cannot apply to all services without knowing their names. So we might have to create a policy that applies to a set of services by name, and then we gradually add the names of the services to the policy? That's not a promotion gate by label.
Alternatively, we can use a different approach: use a gateway and virtual services that are applied at the gateway, and then the gateway does the retries and timeouts? But that would be for ingress/egress.
Given the time, let's simplify:
We are going to design a bundle that consists of:
A PeerAuthentication for the mesh (or namespace) to enforce mTLS.
A DestinationRule and VirtualService that set a default retry policy and timeout for all HTTP services? But we cannot set for all services without listing them.
Alternatively, we can use a wildcard in the host? In Istio, you can use a wildcard in the host of a VirtualService? Actually, you can use "*" as the host to match all hosts? But that is not recommended and might not be supported in all versions.
In Istio 1.6+, you can use a wildcard in the host of a VirtualService? I think you can, but it's not well documented.
Let's check: according to Istio documentation, the hosts field in VirtualService is a list of strings that can include wildcard domain names. So we can set:
hosts:
"*.local"
But that might match too many.
Given the complexity, I think we need to clarify the requirements.
Since the problem says "policy bundle", it might be a concept from a specific service mesh that has a way to bundle policies and apply them by label.
Let's assume we are using a service mesh that supports policy bundles that can be applied to workloads by label. Then we can design:
Bundle:
- mTLS: enabled
- retries: 3 attempts, with 2s interval, on 5xx errors
- timeouts: 2s for HTTP requests
And then we apply this bundle to workloads with label policy-bundle: v1.
Then we can gradually add the label to workloads.
But in Istio, we don't have such a bundle. We have to create multiple resources.
So let's design a set of Istio resources that can be applied conditionally by using a common label selector.
We can use a Sidecar resource to configure the outbound traffic for a workload? But Sidecar is for the workload's own inbound and outbound traffic. We can set the outbound traffic policy to REGISTRY_ONLY and then list the hosts? That doesn't help with retries and timeouts.
Alternatively, we can use a EnvoyFilter to set the retry and timeout for all services? That is too low-level and error-prone.
Given the time, I think we should design a bundle that consists of:
PeerAuthentication (for mTLS) that selects the workloads by label.
A VirtualService that sets the retry and timeout for a set of hosts (which we assume are the services that are labeled). But we have to list the hosts.
How about we generate the VirtualService dynamically for each labeled service? Then we can have a controller that creates a VirtualService for each service that has the label, with the same retry and timeout settings.
But the problem says "design a service mesh policy bundle", so maybe we are to design the YAML for one such policy that can be applied to a service (by having the service's name in the host).
Let's design a policy bundle that is applied per service? Then we can have:
apiVersion: policy.example.com/v1
kind: PolicyBundle
metadata:
name: my-policy-bundle
labels:
target: my-service # or we can use a selector?
spec:
mtls:
enabled: true
retries:
attempts: 3
perTryTimeout: 2s
retryOn: 5xx
timeouts:
timeout: 2s
And then we have a controller that translates this into Istio resources for the service named in target (or selected by label).
But the problem doesn't specify the service mesh, so we can design an abstract bundle.
Alternatively, we can design the bundle as a set of annotations on the service? But again, that's mesh-specific.
Given the ambiguity, I'll design an abstract bundle that can be implemented in any mesh by having a common label selector.
We'll define:
A PeerAuthentication that selects the services with label policy-bundle: enabled and sets mTLS to STRICT.
A VirtualService for each service that has the label, which sets the retry and timeout for that service's host.
But note: the VirtualService for a service B is used by the callers of B. So we need to create a VirtualService for B that sets the retry and timeout for the route to B. That VirtualService will be read by the sidecar of the caller (which may or may not be labeled). So if we want the retry and timeout to apply only when the caller is also labeled? That's not how VirtualService works.
Given the above, I think we have to accept that the retry and timeout policies are applied to all callers of the service, regardless of the caller's labels.
So the promotion gate for retries and timeouts is only on the server side (the service being called) and not on the client side? But the client might not want to retry? Actually, the retry policy is set by the client's configuration, but the VirtualService for the destination (B) is what configures the client's sidecar to retry when calling B. So it's the destination that dictates the retry policy? That's a bit counterintuitive.
In Istio, the retry policy is set in the VirtualService of the destination (the host being called). So when a client calls that host, the client's sidecar will read the VirtualService for that host and apply the retry policy. So the retry policy is associated with the destination, not the client.
So we can create a VirtualService for each service that we want to have retries and timeouts, and that VirtualService will be used by every client that calls that service.
Therefore, we can have:
PeerAuthentication: for the services with label policy-bundle: enabled to enforce mTLS on the server side.
VirtualService: for each service with label policy-bundle: enabled, we create a VirtualService that sets the retry and timeout for that service's host.
But note: the VirtualService must have the same host as the service. We can generate one VirtualService per service.
How do we promote? We add the label policy-bundle: enabled to the service, and then the PeerAuthentication and VirtualService (created by a controller) will apply.
But what about the services that are not labeled? They won't have the PeerAuthentication (so they will use the mesh-level setting, which we might set to PERMISSIVE) and they won't have a VirtualService, so they use default retry (none) and timeout (none? or the sidecar's default?).
So the promotion gate is the label on the service.
Now, we design the PeerAuthentication and a sample VirtualService.
Let's assume we are using Istio.
Step 1: mTLS
We set the mesh-level PeerAuthentication to PERMISSIVE (so that unlabeled services can still communicate without mTLS). Then we create a PeerAuthentication that selects the labeled services and sets mode: STRICT.
Or we can set the mesh-level to STRICT and then create an exception for unlabeled services? But in Istio, you cannot create an exception for unlabeled services by a negative match. So we set mesh-level to PERMISSIVE and then override for labeled services.
Example:
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system # this is for the mesh, if we set at the mesh level by creating in istio-system
spec:
mtls:
mode: PERMISSIVE
Then, for each namespace (or globally) we create a PeerAuthentication that selects the labeled services:
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: strict-mtls
namespace: my-namespace # or we can do it cluster-wide by applying in each namespace? Or use a selector that works across namespaces? PeerAuthentication is namespace-scoped.
spec:
selector:
matchLabels:
policy-bundle: enabled
mtls:
mode: STRICT
Step 2: Retries and Timeouts
For each service with label policy-bundle: enabled, we create a VirtualService:
But note: the VirtualService is for the host (my-service) and will be used by any client that calls my-service. The retry and timeout are set on the route to the destination (my-service). This is client-side configuration (on the caller's sidecar) but the VirtualService is associated with the destination.
So we are setting that when anyone calls my-service, they should retry 3 times on 5xx, with a 2s timeout per try and an overall timeout of 2s? Actually, the timeout in the route is the total timeout for the request, and perTryTimeout is the timeout for each try. So the total time could be up to (attempts * perTryTimeout) but the overall timeout might be less? Actually, the overall timeout is separate.
We set:
retries:
attempts: 3
perTryTimeout: 2s
retryOn: 5xx
timeout: 2s # total timeout for the request
This means: if the first try takes more than 2s, it will be timed out and retried (up to 3 attempts) but each retry also has a 2s per-try timeout? And the overall timeout is 2s, so actually the total time is at most 2s? That doesn't make sense because if we retry, we might exceed 2s.
Let me clarify: the timeout in the route is the total time allowed for the entire request (including retries). The perTryTimeout is the timeout for each individual try. So if we set timeout: 2s and perTryTimeout: 2s and attempts: 3, then the first try will be given 2s, if it times out, then the next try will be given 2s, but the total timeout might be 6s? Actually, the overall timeout is the maximum time from the start of the first try to the end of the last try. So if the first try times out after 2s, then we start the second try, and the overall timeout is still running? Actually, the overall timeout is a deadline from the start. So after 2s from the start, the overall timeout will trigger and no more retries will be sent? That would mean we can only do one try if the first try takes 2s? Because at 2s the overall timeout fires.
So we need to set the overall timeout to be at least (attempts * perTryTimeout) or more. But note that the retries happen only on certain conditions (5xx) and the per-try timeout is for each try. So if we set:
Then we allow up to 3 tries, each try has 2s to complete, and the overall request has 10s. So the maximum time we wait is 10s, but if the first try takes 1s, then the second try starts at 1s and has 2s (so until 3s) and the third try starts at 3s and has 2s (until 5s) and then we wait until 10s? Actually, the overall timeout is the maximum time from the start. So if the third try finishes at 5s, we still wait until 10s? No, we return the response as soon as we get one.
So the overall timeout is the maximum time we are willing to wait for a response, including retries. So we set it to 10s to allow for 3 retries of 2s each (6s) plus some buffer.
But in our example, we set both to 2s? That doesn't make sense.
But the problem says "timeouts", so we might want to set a timeout for the request (overall) and also a per-try timeout for retries? Or maybe we only set the overall timeout and let the per-try be the same? Actually, in Istio, the perTryTimeout is optional and if not set, it uses the overall timeout? Let me check: in Istio, the timeout in the route is the overall timeout, and perTryTimeout is for each retry. If perTryTimeout is not set, then the overall timeout is used for each try? Not exactly.
According to Istio documentation:
timeout: The timeout for the request. This is the total time allowed for the request, including retries.
perTryTimeout: The timeout per retry attempt. If not specified, the timeout value is used.
So if we set timeout: 2s and perTryTimeout is not set, then each retry attempt will have a 2s timeout? And the overall timeout is 2s? Then we cannot do multiple retries because the first try would take 2s and then the overall timeout would be reached? Actually, the overall timeout starts at the beginning of the first try. So if the first try takes 2s, then we have no time left for retries. So we need to set the overall timeout to be longer than the per-try timeout if we want retries to have a chance.
Then each try has 2s, and the overall timeout is 10s, so we can have up to 3 retries (if each fails quickly) and wait up to 10s.
But the problem doesn't specify the values, so we'll leave them as configurable.
Now, the bundle design:
We have two parts:
Part 1: mTLS
We create a PeerAuthentication that selects the services with label policy-bundle: enabled and sets mTLS to STRICT.
Part 2: Retries and Timeouts
We create a VirtualService for each service with label policy-bundle: enabled that sets the retry and timeout for that service.
How do we create the VirtualService? We need to know the service's name and namespace. We can use a controller that watches services with the label and creates a VirtualService for each.
Alternatively, we can design a custom resource that defines the bundle and then have a controller that generates the PeerAuthentication (if not exists) and the VirtualServices.
But the problem says "design a service mesh policy bundle", so maybe we are to define the bundle as a custom resource that can be applied.
Create/update a PeerAuthentication that selects the services matching the selector and sets mtls.mode to the specified mode.
For each service matching the selector, create/update a VirtualService for that service's host with the retry and timeout settings.
But note: the PeerAuthentication and VirtualService are separate resources and we might already have them. So we have to manage them.
This is a high-level design.
Given the constraints, I think we have to accept that the bundle is implemented by a controller that generates the mesh-specific resources.
Alternatively, we can use a tool like Kyverno or OPA Gatekeeper to generate these policies? But that's another story.
Since the problem is to design the bundle, I'll write the YAML for the custom resource and then describe the generated resources.
Let's write:
Custom Resource Definition (CRD) for PolicyBundle:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: policybundles.policy.example.com
spec:
group: policy.example.com
names:
kind: PolicyBundle
plural: policybundles
singular: policybundle
scope: Namespaced # or Cluster? We want to apply to multiple namespaces? Let's make it Namespaced and then we can have one per namespace? Or make it cluster-scoped and have a selector that can match across namespaces? PeerAuthentication is namespace-scoped, so we might need one per namespace.
Actually, PeerAuthentication is namespace-scoped, so if we want to apply to multiple namespaces, we need a PeerAuthentication in each namespace. So we can make the PolicyBundle cluster-scoped and then have a selector that matches services in any namespace? But then we need to create a PeerAuthentication in each namespace that has matching services.
This is getting too complex.
Given the time, I think we should design a bundle that is applied per namespace. Then we can have:
PolicyBundle (namespaced) that applies to services in that namespace with the label.
Then the controller for the PolicyBundle will create:
A PeerAuthentication in the same namespace with the same selector and the mTLS settings.
For each service in the namespace with the label, create a VirtualService in the same namespace for that service.
But note: the VirtualService must be in the same namespace as the service? Actually, the VirtualService can be in any namespace? In Istio, the VirtualService is namespaced, and the host in the VirtualService can be a service in the same namespace or a fully qualified domain name that includes the namespace. So we can create the VirtualService in the same namespace as the service.
So the design:
We have a PolicyBundle in a namespace that says: apply to services in this namespace that have label policy-bundle: enabled.
Then the controller creates:
PeerAuthentication (in the same namespace) that selects those services and sets mTLS.
For each service (in that namespace) with the label, create a VirtualService (in the same namespace) for that service's host (which is the service name, since it's in the same namespace) with the retry and timeout.
my-service # because it's in the same namespace
http:
route:
destination:
host: my-service
port:
number: 80 # we need to know the port? We can get it from the service.
retries:
attempts: 3
perTryTimeout: 2s
retryOn: 5xx
timeout: 10s
But note: the service might have multiple ports. We are only setting for port 80? We should set for all ports? Or we need to know which port is HTTP? We can assume that the service has one HTTP port? Or we can get the port from the service's spec.ports where protocol is HTTP? That's more complex.
Given the complexity, we might limit the bundle to HTTP services and on a specific port (or we set the same for all HTTP ports). But the VirtualService must specify the port.
Alternatively, we can set the retry and timeout in the DestinationRule? But the DestinationRule is for the server-side connection pool and load balancing, not for the client-side retry and timeout? Actually, the retry is in VirtualService and the timeout in VirtualService. The DestinationRule has timeout for TCP and connectionPool settings.
So we are stuck with VirtualService for HTTP retries and timeouts.
Given the above, I think we have to accept that the bundle only applies to HTTP services and we require the service to have a port that we can configure. We can make the port configurable in the bundle? Or we can set the same for all ports? But the VirtualService must specify the port.
Let's change the bundle to include a port number? Or we can set the VirtualService without specifying the port? Then it applies to all ports? Actually, in the route, we must specify the destination port? Or we can omit and it uses the port from the request? I think we have to specify.
Given the time, I'll assume we are only configuring the main HTTP port (usually 80 or 8080) and we set the port to 80.
But that's not flexible.
Alternatively, we can design the bundle to be applied to a set of known services and we create a VirtualService for each service and each port? That's too specific.
Given the complexity of the real world, I think the problem expects a high-level design and not a full implementation.
So I'll summarize:
We design a custom resource PolicyBundle that has:
A selector to select the services (by labels) in the same namespace.
mTLS settings (mode)
retry settings (attempts, perTryTimeout, retryOn)
timeout (overall)
And a controller that:
Creates/updates a PeerAuthentication for the namespace with the selector and the mTLS mode.
For each service matching the selector, creates/updates a VirtualService for that service (with the same name as the service) that sets the retry and timeout for the HTTP port (we assume the service has an HTTP port and we use the first one? or we require the service to have a port named http?).
And we can gradually promote by adding the label policy-bundle: enabled to services.
This is one way.
However, note that the PeerAuthentication and VirtualService are separate resources and might be managed by other controllers. So we have to be careful not to overwrite.
Given the above, I think we have a design.
Let me write the YAML for the custom resource and the generated resources.
But note: the problem says "design a service mesh policy bundle", so maybe they want the bundle YAML and not the custom resource.
Alternatively, we can design the bundle as a set of YAML files that can be applied with a label selector? But we cannot have a label selector in a YAML file.
Given the time, I'll write the custom resource and then the generated resources.
But the problem might be expecting a single YAML that includes all the policies? That's not possible because we need to generate per-service VirtualServices.
So I think the custom resource approach is acceptable.
But note: the service might have multiple HTTP ports? We only set for one? We can set for all ports by creating multiple routes? But we don't know the ports.
Given the complexity, I think we have to assume one HTTP port per service and that we know it. Alternatively, we can set the same retry and timeout for all ports by having multiple routes? But the VirtualService must specify the port in the destination.
We can get the ports from the service and create a route for each port that has protocol HTTP? That would be better.
But for simplicity, let's assume we set for the first port that has name "http" or protocol "HTTP"? That's getting too implementation-specific.
Given the time, I'll leave it as port 80.
This is a design.
However, note that the problem says "configuration promotion gates". We have the promotion by label. So we can gradually add the label to services.
Also, we might want to have multiple bundles (for different environments) and we can have multiple PolicyBundle resources in the same namespace? But they would conflict because they would generate PeerAuthentication with the same selector? Actually, we can have multiple PolicyBundles with different selectors? But then we might have overlapping selectors and the PeerAuthentication and VirtualService would be created multiple times? We need to handle that.
Given the complexity, I think we should stop here.
In summary:
We design a custom resource PolicyBundle that defines mTLS, retries, and timeouts and a selector. A controller then generates the appropriate Istio resources (PeerAuthentication and VirtualService) for the selected services.
This allows promotion by adding the selector label to services.
If we don't want to write a controller, we can use a tool like Kustomize to generate these resources from a template, but that would be static.
Given the problem, I think this is a reasonable design.
Let me know if you have any questions.
I'll design a comprehensive service mesh policy bundle with promotion gates for controlled rollout. This design follows GitOps principles and supports progressive delivery.