首页 > 其他分享 >Kubernetes: manifest template

Kubernetes: manifest template

时间:2023-04-02 19:25:15浏览次数:35  
标签:k8s name Kubernetes -- manifest io etc template pki

 

apiVersion: v1 Kind: pod

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 192.168.8.11:6443
    kubernetes.io/config.hash: 755e36554917832e5f2c40bbb2e580cb
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver-vandal-1
  namespace: kube-system
  # ownerReferences:
  # - apiVersion: v1
  #   controller: true
  #   kind: Node
  #   name: vandal-1
  #   uid: 77f24839-9368-4d4c-a024-4c8452ef2b3d
spec:
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  hostNetwork: true
  nodeName: vandal-1
  preemptionPolicy: PreemptLowerPriority
  priority: 2000001000
  priorityClassName: system-node-critical
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext:
    seccompProfile:
      type: RuntimeDefault
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    operator: Exists
  volumes:
  - hostPath:
      path: /etc/ssl/certs
      type: DirectoryOrCreate
    name: ca-certs
  - hostPath:
      path: /etc/pki
      type: DirectoryOrCreate
    name: etc-pki
  - hostPath:
      path: /etc/kubernetes/pki
      type: DirectoryOrCreate
    name: k8s-certs
  # ~~~~~~ ServiceAccount ~~~~~~
  automountServiceAccountToken: true
  serviceAccountName: codify
  # ^^^^^^ ServiceAccount ^^^^^^
  #---------------------------------------------------------------------
  # Containers
  #---------------------------------------------------------------------
  containers:
  - name: kube-apiserver
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    command:
      - kube-apiserver
      - --advertise-address=192.168.8.11
      - --allow-privileged=true
      - --authorization-mode=Node,RBAC
      - --client-ca-file=/etc/kubernetes/pki/ca.crt
      - --enable-admission-plugins=NodeRestriction
      - --enable-bootstrap-token-auth=true
      - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
      - --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
      - --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
      - --etcd-servers=https://127.0.0.1:2379
      - --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
      - --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
      - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
      - --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
      - --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
      - --requestheader-allowed-names=front-proxy-client
      - --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
      - --requestheader-extra-headers-prefix=X-Remote-Extra-
      - --requestheader-group-headers=X-Remote-Group
      - --requestheader-username-headers=X-Remote-User
      - --secure-port=6443
      - --service-account-issuer=https://kubernetes.default.svc.cluster.local
      - --service-account-key-file=/etc/kubernetes/pki/sa.pub
      - --service-account-signing-key-file=/etc/kubernetes/pki/sa.key
      - --service-cluster-ip-range=10.96.0.0/12
      - --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
      - --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
    image: registry.k8s.io/kube-apiserver:v1.26.0
    imagePullPolicy: IfNotPresent
    # ~~~~~~ Probes ~~~~~~
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 192.168.8.11
        path: /livez
        port: 6443
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 15
    readinessProbe:
      failureThreshold: 3
      httpGet:
        host: 192.168.8.11
        path: /readyz
        port: 6443
        scheme: HTTPS
      periodSeconds: 1
      successThreshold: 1
      timeoutSeconds: 15
    startupProbe:
      failureThreshold: 24
      httpGet:
        host: 192.168.8.11
        path: /livez
        port: 6443
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 15
    # ^^^^^^ Probes ^^^^^^
    # ~~~~~~ Resources ~~~~~~
    resources:
      limits:
        memory: 4Gi
        cpu: 2000m
      requests:
        memory: 100Mi
        cpu: 250m
    # ^^^^^^ Resources ^^^^^^
    # ~~~~~~ VolumeMounts ~~~~~~
    volumeMounts:
    - mountPath: /etc/ssl/certs
      name: ca-certs
      readOnly: true
    - mountPath: /etc/pki
      name: etc-pki
      readOnly: true
    - mountPath: /etc/kubernetes/pki
      name: k8s-certs
      readOnly: true
    # ^^^^^^ VolumeMounts ^^^^^^


apiVersion: rbac.authorization.k8s.io/v1 Kind: Role 

# Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: default
  name: pod-reader
rules:
  - apiGroups: [''] # indicate the core API group
    resources: ['pods']
    verbs: ['get', 'watch', 'list']
  - apiGroups: ['']
    # GET /api/v1/namespaces/{namespace}/pods/{pod}/log
    resources: ['pods/log']
    verbs: ['get', 'list']
  - apiGroups: ['']
    # at HTTP level, the name of the resource for accessing ConfigMap object is 'configmaps'
    resources: ['configmaps']
    resourceNames: ['my-configmap']
    verbs: ['update', 'get']
  - apiGroups: ['batch']
    resources: ['*']
    verbs: ['*']
  - apiGroups: ['apps']
    resources: ['deployments']
    verbs: ['get', 'list', 'watch', 'create', 'update', 'patch', 'delete']
---
# ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: secret-reader
rules:
  - apiGroups: ['']
    resources: ['secrets']
    verbs: ['get', 'watch', 'list']
  - apiGroups: ['']
    resources: ['nodes']
    verbs: ['get', 'list', 'watch']
  - nonResourceURLs: ['/healthz', '/healthz/*']
    verbs: ['get', 'post']
---
# RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: default
  name: read-pods
subjects:
  - kind: User
    name: anatomy # case-sensitive
    apiGroup: rbac.authorization.k8s.io
  - kind: ServiceAccount
    name: default
    namespace: kube-system
  - kind: Group
    name: system:serviceaccounts:qa  # all service accounts in the qa namespace
    apiGroup: rbac.authorization.k8s.io
  - kind: Group
    name: system:serviceaccounts  # all service accounts in any namespace
    apiGroup: rbac.authorization.k8s.io
  - kind: Group
    name: system:authenticated  # for all authenticated users
    apiGroup: rbac.authorization.k8s.io
  - kind: Group
    name: system:unauthenticated  # for all unauthenticated users
    apiGroup: rbac.authorization.k8s.io
roleRef: # roleRef specifies the binding to a Role/ClusterRole
  apiGroup: rbac.authorization.k8s.io
  kind: Role # Role | ClusterRole
  name: pod-reader
---
# ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: read-secrets-global
subjects:
  - kind: Group
    name: manager
    apiGroup: rbac.authorization.k8s.io
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: secret-reader
---
# Aggregated ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: monitoring
aggregationRule:
  clusterRoleSelectors:
    - matchLabels:
        rbac.example.com/aggregate-to-monitoring: 'true'
rules: [] # control plane automatically fills in the rules
---
# Add to Aggregated ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: monitoring-endpoints
  labels:
    rbac.example.com/aggregate-to-monitoring: 'true'
# when you create this ClusterRole, the rules below will be added to the `monitoring` ClusterRole
rules:
  - apiGroups: ['']
    resources: ['services', 'endpointslices', 'pods']
    verbs: ['get', 'list', 'watch']

 

标签:k8s,name,Kubernetes,--,manifest,io,etc,template,pki
From: https://www.cnblogs.com/dissipate/p/17281043.html

相关文章

  • k8s kubernetes给node节点添加标签和删除node节点标签
    [root@k8s-master~]#hostname#查看节点名称k8s-master[root@k8s-master~]#[root@k8s-master~]#kubectlgetnodes--show-labels#查看节点标签NAMESTATUSROLESAGEVERSIONLABELSk8s-masterReadycontrol-plane9dv1.26.0......
  • Kubernetes 基本概念与组件
    Kubernetes(简称K8S)的出现是容器化技术发展的必然结果,容器化是应用程序级别的虚拟化,运行单个内核上有多个独立的用户空间实例,这些实例就是容器;容器提供了将应用程序的代码、运行时、系统工具、系统库和配置打包到一个实例中的标准方法,而且容器是共享一个内核的;由于容器技术的兴起......
  • kubernetes 集群部署rabbimq3.11.11
    通过官方镜像RabbitMQDockerImage和rabbitmq-peer-discovery-k8s插件进行集群部署。0.环境 kubernetes1.24 rabbitmq3.11.111.命名空间将rabbitmq的资源都放在rabbitmq命名空间内。Namespace.yamlapiVersion:v1kind:Namespacemetadata:name:rabbit......
  • SpringBoot 使用RedisTemplate
    1.导入Maven依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>2.配置连接信息spring:redis:host:127.0.0.1......
  • kubernetes Secret使用
    节选rabbitmq的k8s部署部分secret用来配置环境变量1.Secret.yaml:1.1.配置文件secret.yaml apiVersion:v1kind:Secretmetadata:name:rabbitmq-secretnamespace:rabbitmqtype:Opaquedata:RABBITMQ_ERLANG_COOKIE:MTIzajE5dWVkYXM3ZGFkODEwMjNqMTM5ZGph......
  • 基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试 - 3/3
    基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-1/3基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-2/3基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-3/3项目地址:https://github.com/janrs-io/Jgrpc转载请注明来源:https://janrs.com/6rdh......
  • 基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试 - 2/3
    基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-1/3基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-2/3基于Go/Grpc/kubernetes/Istio开发微服务的最佳实践尝试-3/3项目地址:https://github.com/janrs-io/Jgrpc转载请注明来源:https://janrs.com/ugj7......
  • Prometheus服务发现之kubernetes_sd_config
    一、为什么要使用Prometheus服务发现之前我们讲过通过配置prometheus-operator的CRDServiceMonitor来达到K8S集群相关组件和微服务的监控的目的,可以在ServiceMonitor的配......
  • OpenKruise 成为 CNCF 孵化项目:为大规模采用 Kubernetes 打开大门
    作者:OpenKruise社区近期,CNCFTechnicalOversightCommittee(TOC)根据OpenKruise的发展以及社区的接受程度,通过投票决定将OpenKruise升级为CNCF孵化项目。**OpenKruise......
  • Loki日志聚合分析系统-kubernetes
    Promtail介绍Loki是GrafanaLabs团队最新的开源项目,是一个水平可扩展,高可用性,多租户的日志聚合系统。它的设计非常经济高效且易于操作,因为它不会为日志内容编制索引,而......