- How to use
-ocustom-colums
to achieve the same effect as in the PORT(s) column of thekubectl get service
command (i.e. using/
to concatenate the values of the.spec.ports.port
and.spec.ports.protocol
pairs)
# kubectl get service web
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
web ClusterIP 10.222.0.1 <none> 443/TCP 57d
# kubectl get service web -oyaml
apiVersion: v1
kind: Service
metadata:
name: web
spec:
clusterIP: 10.222.0.1
clusterIPs:
- 10.222.0.1
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: https
port: 443
protocol: TCP
targetPort: 8443
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
- And how to add a condition similar to what subject.name specifies in the USERS column if
.subject.kind
==User
# kubectl get rolebindings viewer -owide
NAME ROLE AGE USERS GROUPS SERVICEACCOUNTS
viewer ClusterRole/view 54s view-user view-group
# kubectl get rolebindings viewer -oyaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: viewer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: view-user
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: view-group
directives of the type 'PORTs:.spec.ports.port'/'.spec.ports.protocol'
don’t work