Skip to content

Commit

Permalink
enhanced kompose (#3)
Browse files Browse the repository at this point in the history
* enhanced kompose

- add pre-filter
- support cpu shares
- fix kompose suport volume inaccurate
- change volume name to lower and "-" replace "_"

* enhanced kompose

- add "net" 、 "aliyun.log_ttl_*"  pre-filter
- convert "volumes.name" to lowercase

* enhanced kompose

- add "net" 、 "aliyun.log_ttl_*"  pre-filter
- convert "volumes.name" to lowercase
  • Loading branch information
rjbhewei authored and xianlubird committed May 31, 2019
1 parent 235fac4 commit 70e82c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/loader/compose/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func parseLogConfig(key, path string) (*LogConfig, error) {
typ string
)
path = strings.TrimSpace(path)
name := key[len(LABEL_SLS_PREFIX):]
name := strings.ToLower(key[len(LABEL_SLS_PREFIX):])
if len(name) == 0 {
return nil, fmt.Errorf("invalid SLS label key: %s", key)
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/loader/compose/v1v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ var (
"depends_on": true,
"hostname": true,
"oom-kill-disable": true,
"net": true,
}

delLablesTag = map[string]bool{
"aliyun.log.timestamp": true,
"aliyun.depends": true,
"aliyun.routing.session_sticky": true,
"aliyun.lb.port_": true,
"aliyun.log_ttl_": true,
}

v1v2ParseOptions = config.ParseOptions{
Expand All @@ -75,15 +77,14 @@ var (
if key == "labels" {
v := value.(map[interface{}]interface{})
for k := range v {
k2 := k.(string)
if del, ok := delLablesTag[k2]; ok && del {
if del, ok := delLablesTag[k.(string)]; ok && del {
delete(v, k)
log.Warningf("Unsupported %s label key - ignoring", k2)
log.Warningf("Unsupported %s label key - ignoring", k.(string))
}

if strings.HasPrefix(k2, "aliyun.lb.port_") {
if strings.HasPrefix(k.(string), "aliyun.lb.port_") || strings.HasPrefix(k.(string), "aliyun.log_ttl_") {
delete(v, k)
log.Warningf("Unsupported %s label key - ignoring", k2)
log.Warningf("Unsupported %s label key - ignoring", k.(string))
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/transformer/kubernetes/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/kubernetes/kompose/pkg/kobject"
"k8s.io/kubernetes/pkg/api"
"strings"
)

// ConfigLogVolumes configure the volumes for log.
Expand All @@ -14,7 +15,7 @@ func (k *Kubernetes) ConfigLogVolumes(name string, service kobject.ServiceConfig

for logStore, volume := range service.LogVolumes {
//naming volumes if multiple tmpfs are provided
volumeName := fmt.Sprintf("volumn-sls-%s", logStore)
volumeName := strings.ToLower(fmt.Sprintf("volumn-sls-%s", logStore))
// create a new volume mount object and append to list
volMount := api.VolumeMount{
Name: volumeName,
Expand Down

0 comments on commit 70e82c9

Please sign in to comment.