【k8s】命令configmap

  1. 查看default空间的configmap
➜  ~ kubectl get configmap
NAME                 DATA   AGE
istio-ca-root-cert   1      35d
  1. 查看指定namespace的configmap
➜  ~ kubectl get configmap -n istio-system
NAME                     DATA   AGE
istio                    2      19h
istio-ca-root-cert       1      19h
istio-sidecar-injector   2      19h
kiali                    1      19h
meshinfo                 1      19h
  1. 查看指定namespace的指定名称的configmap
➜  ~ kubectl get configmap istio -n istio-system
NAME    DATA   AGE
istio   2      19h
  1. 查看指定namespace的指定名称的configmap (以yaml格式展示)
➜  ~ kubectl get configmap  -n istio-system istio -o yaml
apiVersion: v1
data:
  mesh: |
    accessLogEncoding: JSON
    accessLogFile: /dev/stdout
    accessLogFormat: '{"authority":"%REQ(:AUTHORITY)%","bytes_received":"%BYTES_RECEIVED%","bytes_sent":"%BYTES_SENT%","downstream_local_address":"%DOWNSTREAM_LOCAL_ADDRESS%","downstream_remote_address":"%DOWNSTREAM_REMOTE_ADDRESS%","duration":"%DURATION%","istio_policy_status":"%DYNAMIC_METADATA(istio.mixer:status)%","method":"%REQ(:METHOD)%","path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","protocol":"%PROTOCOL%","request_id":"%REQ(X-REQUEST-ID)%","requested_server_name":"%REQUESTED_SERVER_NAME%","response_code":"%RESPONSE_CODE%","response_flags":"%RESPONSE_FLAGS%","route_name":"%ROUTE_NAME%","start_time":"%START_TIME%","trace_id":"%REQ(X-B3-TRACEID)%","upstream_cluster":"%UPSTREAM_CLUSTER%","upstream_host":"%UPSTREAM_HOST%","upstream_local_address":"%UPSTREAM_LOCAL_ADDRESS%","upstream_service_time":"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%","upstream_transport_failure_reason":"%UPSTREAM_TRANSPORT_FAILURE_REASON%","user_agent":"%REQ(USER-AGENT)%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%"}'
    certificates: []
    defaultConfig:
      binaryPath: /usr/local/bin/envoy
      concurrency: 2
      configPath: /etc/istio/proxy
      controlPlaneAuthPolicy: MUTUAL_TLS
      discoveryAddress: istiod.istio-system.svc:15012
      drainDuration: 45s
      parentShutdownDuration: 1m0s
      proxyAdminPort: 15000
      proxyMetadata:
        DNS_AGENT: ""
      serviceCluster: istio-proxy
    disableMixerHttpReports: true
    disablePolicyChecks: true
    dnsRefreshRate: 300s
    enableAutoMtls: true
    enableEnvoyAccessLogService: false
    enablePrometheusMerge: false
    enableTracing: false
    mixerCheckServer: istio-policy.istio-system:15004
    mixerReportServer: istio-telemetry.istio-system:15004
    outboundTrafficPolicy:
      mode: ALLOW_ANY
    policyCheckFailOpen: true
    protocolDetectionTimeout: 100ms
    reportBatchMaxEntries: 0
    reportBatchMaxTime: 1s
    rootNamespace: istio-system
    sdsUdsPath: unix:/etc/istio/proxy/SDS
    sidecarToTelemetrySessionAffinity: false
    trustDomain: cluster.local
    trustDomainAliases: []
  meshNetworks: |
    null
kind: ConfigMap
metadata:
  annotations:
    servicemesh.alibabacloud.com/last-applied: UEsDBBQACAAIAAAAAAAAAAAAAAAAAAAAAAAIAAAAb3JpZ2luYWx0Vm1v2zgT/CsCgaJ9ADu2m6R9yi8H1mIaH2zJlej0gqoQaGkVE5FIH0k5MYr89wP1FtfX+2ILnBlyd3a50k+Uc8sR/okqMDuEEc8yMGapHqjMVC7kA/b+jMMgkQNwI0rA3iSHw8TYXNX2FFO64hZ7b38miNd2p7SwxwThBL2J6Nd3mGzYbRgt2P3/3iRolKDt0YJJNWQgDpC3xM/3jMZpROd0cUf9U54BaU85MQ1Yi+fqSRqrgVdpqTJepjzPNRjTsv3wWxCziJJVugznZJkS349oHP9Lq6FSFv5THNFVyOiZutbcCiU78iYibBEGLSaMFSrdq1Jkx9RYbut+z/uArBbzdEUZ8Qkj7xrmRSWeQeOW2BlUgd2p/MTBFWW3od+he253r9hfYxrchffjMFp8WQRkOV4TdvsHdr89XyurMlW2mnUUsnAeLltMw981GJuK/HTHiH7d0JiNF/2RHQ3y1IA+gE4lr2BQOC7105hGd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dJG1K49C5gijxUlcQ0jtIEIjVAvH+fjp/x+vP15vx+/zq9n46sN0Ot5eFjC+nML2wxQ+beEyQy8/Xl7+CQAA//9QSwcI89DiL90EAACmCQAAUEsBAhQAFAAIAAgAAAAAAPPQ4i/dBAAApgkAAAgAAAAAAAAAAAAAAAAAAAAAAG9yaWdpbmFsUEsFBgAAAAABAAEANgAAABMFAAAAAA==
  creationTimestamp: "2021-05-24T07:06:57Z"
  labels:
    app: istio
    asm-system: "true"
    provider: asm
  name: istio
  namespace: istio-system
  ownerReferences:
  - apiVersion: istio.alibabacloud.com/v1beta1
    blockOwnerDeletion: true
    controller: true
    kind: Istio
    name: istio-config
    uid: 7987575b-2d41-4600-b3fe-30eb60e9be3c
  resourceVersion: "333076575"
  selfLink: /api/v1/namespaces/istio-system/configmaps/istio
  uid: eb5632a9-5dc4-418d-a5de-d80d0622092f
  1. 根据关键字过滤
➜  ~ kubectl get configmap istio -n istio-system -o yaml | grep -o "mode: ALLOW_ANY"
mode: ALLOW_ANY
  1. 替换mode
➜  ~ kubectl get configmap istio -n istio-system -o yaml | sed 's/mode: ALLOW_ANY/mode: REGISTRY_ONLY/g' | kubectl replace -n istio-system -f -

configmap/istio replaced
  1. 恢复mode
kubectl get configmap istio -n istio-system -o yaml | sed 's/mode: REGISTRY_ONLY/mode: ALLOW_ANY/g' | kubectl replace -n istio-system -f -

你可能感兴趣的:(【k8s】命令configmap)