Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Support domain alias in fence module config #46

Merged
merged 2 commits into from
Apr 1, 2022

Conversation

cywang1905
Copy link
Contributor

@cywang1905 cywang1905 commented Mar 31, 2022

New feature

This feature supports adding the name of the dependent target service and a set of its regular matches, converted by a field domainAlias, to the sidecarscope.

message Fence {
  // ...  
  // domain alias rule
  repeated DomainAlias domainAlias = 5;
}

message DomainAlias {
  string pattern = 1;
  repeated string templates = 2;
}

Supports both static and dynamic dependent target service.

Usage example

Add domainAlias with single inverted commas in fence module config

apiVersion: config.netease.com/v1alpha1
kind: SlimeBoot
metadata:
  name: lazyload
  namespace: mesh-operator
spec:
  module:
    - name: lazyload-test
      kind: lazyload
      enable: true
      general:
        wormholePort: # replace to your application service ports, and extend the list in case of multi ports
          - "9080"
        domainAliases: 
          - pattern: '(?P<service>[^\.]+)\.(?P<namespace>[^\.]+)\.svc\.cluster\.local$'
            templates:
              - "$namespace.$service.mailsaas"
  #...

serviceFence example

apiVersion: microservice.slime.io/v1alpha1
kind: ServiceFence
metadata:
  name: ratings
  namespace: default
spec:
  enable: true
  host:
    details.default.svc.cluster.local: # static dependent service
      stable: {}
status:
  domains:
    default.details.mailsaas: # static dependent service converted result
      hosts:
      - default.details.mailsaas
    default.productpage.mailsaas: # dynamic dependent service converted result
      hosts:
      - default.productpage.mailsaas
    details.default.svc.cluster.local:
      hosts:
      - details.default.svc.cluster.local
    productpage.default.svc.cluster.local:
      hosts:
      - productpage.default.svc.cluster.local
  metricStatus:
    '{destination_service="productpage.default.svc.cluster.local"}': "1" # dynamic dependent service

sidecar example

apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
  name: ratings
  namespace: default
spec:
  egress:
  - hosts:
    - '*/default.details.mailsaas' # static dependent service converted result
    - '*/default.productpage.mailsaas' # dynamic dependent service converted result
    - '*/details.default.svc.cluster.local'
    - '*/productpage.default.svc.cluster.local'
    - istio-system/*
    - mesh-operator/*
  workloadSelector:
    labels:
      app: ratings

// regexp expression, which is alias for target domain, format is 'pattern=template1,template2'
// default value is empty
// example: (?P<service>[^\.]+)\.(?P<namespace>[^\.]+)\.svc\.cluster\.local(?P<port>[^\.]+)?$=$namespace.$service.service.mailsaas$port
string domainAlias = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a structured data type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message Fence {
  // ...
  DomainAlias domainAlias = 5;
}

message DomainAlias {
  string pattern = 1;
  repeated string template = 2;
}

@@ -18,6 +18,10 @@ message Fence {
repeated string namespace = 3;
// custom outside dispatch traffic rules
repeated Dispatch dispatches = 4;
// regexp expression, which is alias for target domain, format is 'pattern=template1,template2'
// default value is empty
// example: (?P<service>[^\.]+)\.(?P<namespace>[^\.]+)\.svc\.cluster\.local(?P<port>[^\.]+)?$=$namespace.$service.service.mailsaas$port
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider whether we allow port here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no port here

@@ -18,6 +18,8 @@ message Fence {
repeated string namespace = 3;
// custom outside dispatch traffic rules
repeated Dispatch dispatches = 4;

DomainAlias domainAlias = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repeated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@YonkaFang YonkaFang merged commit 78f3d09 into slime-io:master Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants