Skip to content

Commit 16b596d

Browse files
committed
feat: remove cluster role requirement for list namespaces
1 parent 7bef5cc commit 16b596d

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

docs/deploy/rbac/all-commands-mini.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# minimal permission role for all kt commands can run
22
apiVersion: rbac.authorization.k8s.io/v1
3-
kind: ClusterRole
4-
metadata:
5-
name: kt-cluster-role
6-
rules:
7-
- apiGroups:
8-
- ""
9-
resources:
10-
- namespaces
11-
verbs:
12-
- list
13-
---
14-
apiVersion: rbac.authorization.k8s.io/v1
153
kind: Role
164
metadata:
175
name: kt-role

docs/deploy/rbac/connect-only-mini.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# minimal permission role for connect command can run
22
apiVersion: rbac.authorization.k8s.io/v1
3-
kind: ClusterRole
4-
metadata:
5-
name: kt-cluster-role
6-
rules:
7-
- apiGroups:
8-
- ""
9-
resources:
10-
- namespaces
11-
verbs:
12-
- list
13-
---
14-
apiVersion: rbac.authorization.k8s.io/v1
153
kind: Role
164
metadata:
175
name: kt-role

pkg/kt/service/dns/dns_darwin.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ func (s *Cli) SetNameServer(dnsServer string) error {
2929
return err
3030
}
3131
go func() {
32+
var nsList []string
3233
namespaces, err := cluster.Ins().GetAllNamespaces()
3334
if err != nil {
34-
dnsSignal <-err
35-
return
35+
log.Info().Msgf("Cannot list all namespaces, set dns for '%s' only", opt.Get().Global.Namespace)
36+
nsList = append(nsList, opt.Get().Global.Namespace)
37+
} else {
38+
for _, ns := range namespaces.Items {
39+
nsList = append(nsList, ns.Name)
40+
}
3641
}
3742

3843
preferredDnsInfo := strings.Split(dnsServer, ":")
@@ -43,8 +48,8 @@ func (s *Cli) SetNameServer(dnsServer string) error {
4348
}
4449

4550
createResolverFile("local", opt.Get().Connect.ClusterDomain, dnsIp, dnsPort)
46-
for _, ns := range namespaces.Items {
47-
createResolverFile(fmt.Sprintf("%s.local", ns.Name), ns.Name, dnsIp, dnsPort)
51+
for _, ns := range nsList {
52+
createResolverFile(fmt.Sprintf("%s.local", ns), ns, dnsIp, dnsPort)
4853
}
4954
dnsSignal <- nil
5055

0 commit comments

Comments
 (0)