Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module name and kind decoupling #140

Merged
merged 2 commits into from
Mar 7, 2022
Merged

Conversation

cywang1905
Copy link
Contributor

@cywang1905 cywang1905 commented Mar 3, 2022

In previous version, we use spec.module.name to indicate module kind, thus custom name field is not supported. Also, multiple modules of the same type in the same aggregated image are also not supported.

# single module
spec:  
  module:
    - name: lazyload # name is kind
      enable: true
# bundle module
spec:
  module:
    - name: bundle-example-all
      enable: true
      bundle:
        modules:
          - name: lazyload # name is kind
          - name: plugin
    - name: lazyload
      enable: true
      mode: BundleItem
      fence:
        wormholePort:
          - "9080"
    - name: plugin
      enable: true
      mode: BundleItem

Now we add kind field for module and submodule to solve these problems.

single module

# single module
spec:  
  module:
    - name: lazyload-test
      kind: lazyload
      enable: true

bundle module

A full example of bundle module code and config yaml files can be found in bundle_example

// this main func means bundle item kind can be lazyload, limiter or plugin. 
// And bundle items number can be any value.
func main() {
	module.Main([]module.Module{
		&lazyloadmod.Module{},
		&limitermod.Module{},
		&pluginmod.Module{},
	})
}

Priority of the same configuration item: sub module > main module > default value.
Here is an example config of lazyload-bundle, which contains 2 lazyload module with different revision.

---
apiVersion: config.netease.com/v1alpha1
kind: SlimeBoot
metadata:
  name: lazyload-bundle
  namespace: mesh-operator
spec:
  image:
    pullPolicy: Always
    repository: registry.cn-hangzhou.aliyuncs.com/slimeio/slime-bundle-example-all
    tag: v0.3.11_linux_amd64-dirty_  # should be replaced with actual repo/tag
  module:
    - name: lazyload-bundle
      enable: true
      bundle:
        modules:
          - name: lazyload-v1
            kind: lazyload
          - name: lazyload-v2
            kind: lazyload
      global:
        log:
          logLevel: debug
    - name: lazyload-v1
      kind: lazyload
      enable: true
      mode: BundleItem
      general:
        wormholePort: # replace to your application svc ports
          - "9080"
        namespace:
          - default
      global:
        istioRev: v1
        misc:
          globalSidecarMode: namespace
          metricSourceType: accesslog
    - name: lazyload-v2
      kind: lazyload
      enable: true
      mode: BundleItem
      general:
        wormholePort: # replace to your application svc ports
          - "80"
        namespace:
          - test
      global:
        istioRev: v2
        strictRev: true
        misc:
          globalSidecarMode: namespace
          metricSourceType: accesslog
  component:  # for lazyload
    globalSidecar:
      enable: true
      sidecarInject:
        enable: true
        mode: pod
        labels: # optional, used for sidecarInject.mode = pod
          sidecar.istio.io/inject: "true"
          # istio.io/rev: canary # use control plane revisions
      resources:
        requests:
          cpu: 200m
          memory: 200Mi
        limits:
          cpu: 400m
          memory: 400Mi
      image:
        repository: registry.cn-hangzhou.aliyuncs.com/slimeio/slime-global-sidecar
        tag: v0.2.0-1b93bf7

@YonkaFang
Copy link
Contributor

I think we should note that a significat meaning of name-type decoupling is that the module is no longer an unique thing and users can add multiple instances of an exact module as they wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants