nginx-ingress-controller的日志
    nginx-ingress-controller的日志包括三个部分:

    • controller日志: 输出到stdout,通过启动参数中的–log_dir可已配置输出到文件,重定向到文件后会自动轮转,但不会自动清理
    • accesslog:输出到stdout,通过nginx-configuration中的字段可以配置输出到哪个文件。输出到文件后不会自动轮转或清理
    • errorlog:输出到stderr,配置方式与accesslog类似。

    给controller日志落盘

    • 给nginx-ingress-controller挂一个hostpath: /data/log/nginx/ 映射到容器里的/var/log/nginx/ ,
    • 给nginx-ingress-controller配置log-dir和logtostderr参数,将日志重定向到/var/log/nginx/中。

    controller的日志需要做定时清理。由于controller的日志是通过klog(k8s.io/klog)输出的,会进行日志滚动,所以我们通过脚本定时清理一定时间之前的日志文件即可。
    给nginx日志落盘
    修改configmap: nginx-configuration。配置accesslog和errorlog的输出路径,替换默认的stdout和stderr。输出路径我们可以与controller一致,便于查找。
    accesslog和errorlog都只有一个日志文件,我们可以使用logrotate进行日志轮转,将输出到宿主机上的日志进行轮转和清理。配置如:

    1. $ cat /etc/logrotate.d/nginx.log
    2. /data/log/nginx/access.log {
    3. su root list
    4. rotate 7
    5. daily
    6. maxsize 50M
    7. copytruncate
    8. missingok
    9. create 0644 www-data root
    10. }

    官方提供的模板中,nginx-ingress-controller默认都是以33这个用户登录启动容器的,因此挂载hostpath路径时存在权限问题。我们需要手动在机器上执行chown -R 33:33 /data/log/nginx.
    自动化
    nginx日志落盘中,第2、3两点均需要人工运维,有什么解决办法吗?
    问题的关键是:有什么办法可以在nginx-ingress-controller容器启动之前加一个hook,将宿主机的指定目录执行chown呢?
    可以用initContainer。initcontainer必须在containers中的容器运行前运行完毕并成功退出。再说第二点,我们注意到nginx-ingress-controller的基础镜像中就自带了logrotate,那么问题就简单了,我们将写好的logrotate配置文件以configmap的形式挂载到容器中就可以了。
    完整的yaml文件如下:

    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: ingress-nginx
    5. labels:
    6. app.kubernetes.io/name: ingress-nginx
    7. app.kubernetes.io/instance: ingress-nginx
    8. ---
    9. # Source: ingress-nginx/templates/controller-serviceaccount.yaml
    10. apiVersion: v1
    11. kind: ServiceAccount
    12. metadata:
    13. labels:
    14. helm.sh/chart: ingress-nginx-2.0.3
    15. app.kubernetes.io/name: ingress-nginx
    16. app.kubernetes.io/instance: ingress-nginx
    17. app.kubernetes.io/version: 0.32.0
    18. app.kubernetes.io/managed-by: Helm
    19. app.kubernetes.io/component: controller
    20. name: ingress-nginx
    21. namespace: ingress-nginx
    22. ---
    23. # Source: ingress-nginx/templates/controller-configmap.yaml
    24. apiVersion: v1
    25. kind: ConfigMap
    26. metadata:
    27. labels:
    28. helm.sh/chart: ingress-nginx-2.0.3
    29. app.kubernetes.io/name: ingress-nginx
    30. app.kubernetes.io/instance: ingress-nginx
    31. app.kubernetes.io/version: 0.32.0
    32. app.kubernetes.io/managed-by: Helm
    33. app.kubernetes.io/component: controller
    34. name: ingress-nginx-controller
    35. namespace: ingress-nginx
    36. data:
    37. client_max_body_size: "100m"
    38. proxy_body_size: "100m"
    39. access-log-path: /var/log/nginx/access.log
    40. error-log-path: /var/log/nginx/erroes.log
    41. ---
    42. # 创建一个configmap,配置nginx日志的轮转策略,对应的是nginx日志在容器内的日志文件
    43. apiVersion: v1
    44. data:
    45. nginx.log: |
    46. /var/log/nginx/access.log {
    47. rotate 7
    48. daily
    49. maxsize 200M
    50. minsize 10M
    51. copytruncate
    52. missingok
    53. create 0644 root root
    54. }
    55. /var/log/nginx/error.log {
    56. rotate 7
    57. daily
    58. maxsize 200M
    59. minsize 10M
    60. copytruncate
    61. missingok
    62. create 0644 root root
    63. }
    64. kind: ConfigMap
    65. metadata:
    66. name: nginx-ingress-logrotate
    67. namespace: ingress-nginx
    68. ---
    69. # Source: ingress-nginx/templates/clusterrole.yaml
    70. apiVersion: rbac.authorization.k8s.io/v1
    71. kind: ClusterRole
    72. metadata:
    73. labels:
    74. helm.sh/chart: ingress-nginx-2.0.3
    75. app.kubernetes.io/name: ingress-nginx
    76. app.kubernetes.io/instance: ingress-nginx
    77. app.kubernetes.io/version: 0.32.0
    78. app.kubernetes.io/managed-by: Helm
    79. name: ingress-nginx
    80. namespace: ingress-nginx
    81. rules:
    82. - apiGroups:
    83. - ''
    84. resources:
    85. - configmaps
    86. - endpoints
    87. - nodes
    88. - pods
    89. - secrets
    90. verbs:
    91. - list
    92. - watch
    93. - apiGroups:
    94. - ''
    95. resources:
    96. - nodes
    97. verbs:
    98. - get
    99. - apiGroups:
    100. - ''
    101. resources:
    102. - services
    103. verbs:
    104. - get
    105. - list
    106. - update
    107. - watch
    108. - apiGroups:
    109. - extensions
    110. - networking.k8s.io # k8s 1.14+
    111. resources:
    112. - ingresses
    113. verbs:
    114. - get
    115. - list
    116. - watch
    117. - apiGroups:
    118. - ''
    119. resources:
    120. - events
    121. verbs:
    122. - create
    123. - patch
    124. - apiGroups:
    125. - extensions
    126. - networking.k8s.io # k8s 1.14+
    127. resources:
    128. - ingresses/status
    129. verbs:
    130. - update
    131. - apiGroups:
    132. - networking.k8s.io # k8s 1.14+
    133. resources:
    134. - ingressclasses
    135. verbs:
    136. - get
    137. - list
    138. - watch
    139. ---
    140. # Source: ingress-nginx/templates/clusterrolebinding.yaml
    141. apiVersion: rbac.authorization.k8s.io/v1
    142. kind: ClusterRoleBinding
    143. metadata:
    144. labels:
    145. helm.sh/chart: ingress-nginx-2.0.3
    146. app.kubernetes.io/name: ingress-nginx
    147. app.kubernetes.io/instance: ingress-nginx
    148. app.kubernetes.io/version: 0.32.0
    149. app.kubernetes.io/managed-by: Helm
    150. name: ingress-nginx
    151. namespace: ingress-nginx
    152. roleRef:
    153. apiGroup: rbac.authorization.k8s.io
    154. kind: ClusterRole
    155. name: ingress-nginx
    156. subjects:
    157. - kind: ServiceAccount
    158. name: ingress-nginx
    159. namespace: ingress-nginx
    160. ---
    161. # Source: ingress-nginx/templates/controller-role.yaml
    162. apiVersion: rbac.authorization.k8s.io/v1
    163. kind: Role
    164. metadata:
    165. labels:
    166. helm.sh/chart: ingress-nginx-2.0.3
    167. app.kubernetes.io/name: ingress-nginx
    168. app.kubernetes.io/instance: ingress-nginx
    169. app.kubernetes.io/version: 0.32.0
    170. app.kubernetes.io/managed-by: Helm
    171. app.kubernetes.io/component: controller
    172. name: ingress-nginx
    173. namespace: ingress-nginx
    174. rules:
    175. - apiGroups:
    176. - ''
    177. resources:
    178. - namespaces
    179. verbs:
    180. - get
    181. - apiGroups:
    182. - ''
    183. resources:
    184. - configmaps
    185. - pods
    186. - secrets
    187. - endpoints
    188. verbs:
    189. - get
    190. - list
    191. - watch
    192. - apiGroups:
    193. - ''
    194. resources:
    195. - services
    196. verbs:
    197. - get
    198. - list
    199. - update
    200. - watch
    201. - apiGroups:
    202. - extensions
    203. - networking.k8s.io # k8s 1.14+
    204. resources:
    205. - ingresses
    206. verbs:
    207. - get
    208. - list
    209. - watch
    210. - apiGroups:
    211. - extensions
    212. - networking.k8s.io # k8s 1.14+
    213. resources:
    214. - ingresses/status
    215. verbs:
    216. - update
    217. - apiGroups:
    218. - networking.k8s.io # k8s 1.14+
    219. resources:
    220. - ingressclasses
    221. verbs:
    222. - get
    223. - list
    224. - watch
    225. - apiGroups:
    226. - ''
    227. resources:
    228. - configmaps
    229. resourceNames:
    230. - ingress-controller-leader-nginx
    231. verbs:
    232. - get
    233. - update
    234. - apiGroups:
    235. - ''
    236. resources:
    237. - configmaps
    238. verbs:
    239. - create
    240. - apiGroups:
    241. - ''
    242. resources:
    243. - endpoints
    244. verbs:
    245. - create
    246. - get
    247. - update
    248. - apiGroups:
    249. - ''
    250. resources:
    251. - events
    252. verbs:
    253. - create
    254. - patch
    255. ---
    256. # Source: ingress-nginx/templates/controller-rolebinding.yaml
    257. apiVersion: rbac.authorization.k8s.io/v1
    258. kind: RoleBinding
    259. metadata:
    260. labels:
    261. helm.sh/chart: ingress-nginx-2.0.3
    262. app.kubernetes.io/name: ingress-nginx
    263. app.kubernetes.io/instance: ingress-nginx
    264. app.kubernetes.io/version: 0.32.0
    265. app.kubernetes.io/managed-by: Helm
    266. app.kubernetes.io/component: controller
    267. name: ingress-nginx
    268. namespace: ingress-nginx
    269. roleRef:
    270. apiGroup: rbac.authorization.k8s.io
    271. kind: Role
    272. name: ingress-nginx
    273. subjects:
    274. - kind: ServiceAccount
    275. name: ingress-nginx
    276. namespace: ingress-nginx
    277. ---
    278. # Source: ingress-nginx/templates/controller-service-webhook.yaml
    279. apiVersion: v1
    280. kind: Service
    281. metadata:
    282. labels:
    283. helm.sh/chart: ingress-nginx-2.0.3
    284. app.kubernetes.io/name: ingress-nginx
    285. app.kubernetes.io/instance: ingress-nginx
    286. app.kubernetes.io/version: 0.32.0
    287. app.kubernetes.io/managed-by: Helm
    288. app.kubernetes.io/component: controller
    289. name: ingress-nginx-controller-admission
    290. namespace: ingress-nginx
    291. spec:
    292. type: ClusterIP
    293. ports:
    294. - name: https-webhook
    295. port: 443
    296. targetPort: webhook
    297. selector:
    298. app.kubernetes.io/name: ingress-nginx
    299. app.kubernetes.io/instance: ingress-nginx
    300. app.kubernetes.io/component: controller
    301. ---
    302. # Source: ingress-nginx/templates/controller-service.yaml
    303. apiVersion: v1
    304. kind: Service
    305. metadata:
    306. labels:
    307. helm.sh/chart: ingress-nginx-2.0.3
    308. app.kubernetes.io/name: ingress-nginx
    309. app.kubernetes.io/instance: ingress-nginx
    310. app.kubernetes.io/version: 0.32.0
    311. app.kubernetes.io/managed-by: Helm
    312. app.kubernetes.io/component: controller
    313. name: ingress-nginx-controller
    314. namespace: ingress-nginx
    315. spec:
    316. type: LoadBalancer
    317. externalTrafficPolicy: Local
    318. ports:
    319. - name: http
    320. port: 80
    321. protocol: TCP
    322. targetPort: http
    323. - name: https
    324. port: 443
    325. protocol: TCP
    326. targetPort: https
    327. selector:
    328. app.kubernetes.io/name: ingress-nginx
    329. app.kubernetes.io/instance: ingress-nginx
    330. app.kubernetes.io/component: controller
    331. ---
    332. # Source: ingress-nginx/templates/controller-deployment.yaml
    333. apiVersion: apps/v1
    334. kind: Deployment
    335. metadata:
    336. labels:
    337. helm.sh/chart: ingress-nginx-2.0.3
    338. app.kubernetes.io/name: ingress-nginx
    339. app.kubernetes.io/instance: ingress-nginx
    340. app.kubernetes.io/version: 0.32.0
    341. app.kubernetes.io/managed-by: Helm
    342. app.kubernetes.io/component: controller
    343. name: ingress-nginx-controller
    344. namespace: ingress-nginx
    345. spec:
    346. selector:
    347. matchLabels:
    348. app.kubernetes.io/name: ingress-nginx
    349. app.kubernetes.io/instance: ingress-nginx
    350. app.kubernetes.io/component: controller
    351. revisionHistoryLimit: 10
    352. minReadySeconds: 0
    353. replicas: 1
    354. template:
    355. metadata:
    356. labels:
    357. app.kubernetes.io/name: ingress-nginx
    358. app.kubernetes.io/instance: ingress-nginx
    359. app.kubernetes.io/component: controller
    360. spec:
    361. dnsPolicy: ClusterFirst
    362. hostNetwork: true
    363. tolerations:
    364. - operator: "Exists"
    365. nodeSelector:
    366. kubernetes.io/hostname: k8s-master-134
    367. initContainers:
    368. - name: adddirperm
    369. image: busybox
    370. command:
    371. - /bin/sh
    372. - -c
    373. - chown -R ${USER_ID}:${USER_ID} ${LOG_DIR}
    374. env:
    375. - name: LOG_DIR
    376. value: /var/log/nginx
    377. - name: USER_ID
    378. value: "101"
    379. volumeMounts:
    380. - name: logdir
    381. mountPath: /var/log/nginx
    382. containers:
    383. - name: controller
    384. image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.32.0
    385. imagePullPolicy: IfNotPresent
    386. lifecycle:
    387. preStop:
    388. exec:
    389. command:
    390. - /wait-shutdown
    391. args:
    392. - /nginx-ingress-controller
    393. - --publish-service=ingress-nginx/ingress-nginx-controller
    394. - --election-id=ingress-controller-leader
    395. - --ingress-class=nginx
    396. - --configmap=ingress-nginx/ingress-nginx-controller
    397. - --validating-webhook=:8443
    398. - --validating-webhook-certificate=/usr/local/certificates/cert
    399. - --validating-webhook-key=/usr/local/certificates/key
    400. - --log_dir=/var/log/nginx
    401. - --logtostderr=false
    402. securityContext:
    403. capabilities:
    404. drop:
    405. - ALL
    406. add:
    407. - NET_BIND_SERVICE
    408. runAsUser: 101
    409. allowPrivilegeEscalation: true
    410. env:
    411. - name: POD_NAME
    412. valueFrom:
    413. fieldRef:
    414. fieldPath: metadata.name
    415. - name: POD_NAMESPACE
    416. valueFrom:
    417. fieldRef:
    418. fieldPath: metadata.namespace
    419. livenessProbe:
    420. httpGet:
    421. path: /healthz
    422. port: 10254
    423. scheme: HTTP
    424. initialDelaySeconds: 10
    425. periodSeconds: 10
    426. timeoutSeconds: 1
    427. successThreshold: 1
    428. failureThreshold: 3
    429. readinessProbe:
    430. httpGet:
    431. path: /healthz
    432. port: 10254
    433. scheme: HTTP
    434. initialDelaySeconds: 10
    435. periodSeconds: 10
    436. timeoutSeconds: 1
    437. successThreshold: 1
    438. failureThreshold: 3
    439. ports:
    440. - name: http
    441. containerPort: 80
    442. protocol: TCP
    443. - name: https
    444. containerPort: 443
    445. protocol: TCP
    446. - name: webhook
    447. containerPort: 8443
    448. protocol: TCP
    449. volumeMounts:
    450. - name: webhook-cert
    451. mountPath: /usr/local/certificates/
    452. readOnly: true
    453. - name: logdir
    454. mountPath: /var/log/nginx
    455. - name: logrotateconf
    456. mountPath: /etc/logrotate.d/nginx.log
    457. subPath: nginx.log
    458. resources:
    459. requests:
    460. cpu: 100m
    461. memory: 90Mi
    462. serviceAccountName: ingress-nginx
    463. terminationGracePeriodSeconds: 300
    464. volumes:
    465. - name: webhook-cert
    466. secret:
    467. secretName: ingress-nginx-admission
    468. - name: logdir
    469. hostPath:
    470. path: /var/log/nginx
    471. type: DirectoryOrCreate
    472. - name: logrotateconf
    473. configMap:
    474. name: nginx-ingress-logrotate
    475. items:
    476. - key: nginx.log
    477. path: nginx.log
    478. ---
    479. # Source: ingress-nginx/templates/admission-webhooks/validating-webhook.yaml
    480. apiVersion: admissionregistration.k8s.io/v1beta1
    481. kind: ValidatingWebhookConfiguration
    482. metadata:
    483. labels:
    484. helm.sh/chart: ingress-nginx-2.0.3
    485. app.kubernetes.io/name: ingress-nginx
    486. app.kubernetes.io/instance: ingress-nginx
    487. app.kubernetes.io/version: 0.32.0
    488. app.kubernetes.io/managed-by: Helm
    489. app.kubernetes.io/component: admission-webhook
    490. name: ingress-nginx-admission
    491. namespace: ingress-nginx
    492. webhooks:
    493. - name: validate.nginx.ingress.kubernetes.io
    494. rules:
    495. - apiGroups:
    496. - extensions
    497. - networking.k8s.io
    498. apiVersions:
    499. - v1beta1
    500. operations:
    501. - CREATE
    502. - UPDATE
    503. resources:
    504. - ingresses
    505. failurePolicy: Fail
    506. clientConfig:
    507. service:
    508. namespace: ingress-nginx
    509. name: ingress-nginx-controller-admission
    510. path: /extensions/v1beta1/ingresses
    511. ---
    512. # Source: ingress-nginx/templates/admission-webhooks/job-patch/clusterrole.yaml
    513. apiVersion: rbac.authorization.k8s.io/v1
    514. kind: ClusterRole
    515. metadata:
    516. name: ingress-nginx-admission
    517. annotations:
    518. helm.sh/hook: pre-install,pre-upgrade,post-install,post-upgrade
    519. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    520. labels:
    521. helm.sh/chart: ingress-nginx-2.0.3
    522. app.kubernetes.io/name: ingress-nginx
    523. app.kubernetes.io/instance: ingress-nginx
    524. app.kubernetes.io/version: 0.32.0
    525. app.kubernetes.io/managed-by: Helm
    526. app.kubernetes.io/component: admission-webhook
    527. namespace: ingress-nginx
    528. rules:
    529. - apiGroups:
    530. - admissionregistration.k8s.io
    531. resources:
    532. - validatingwebhookconfigurations
    533. verbs:
    534. - get
    535. - update
    536. ---
    537. # Source: ingress-nginx/templates/admission-webhooks/job-patch/clusterrolebinding.yaml
    538. apiVersion: rbac.authorization.k8s.io/v1
    539. kind: ClusterRoleBinding
    540. metadata:
    541. name: ingress-nginx-admission
    542. annotations:
    543. helm.sh/hook: pre-install,pre-upgrade,post-install,post-upgrade
    544. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    545. labels:
    546. helm.sh/chart: ingress-nginx-2.0.3
    547. app.kubernetes.io/name: ingress-nginx
    548. app.kubernetes.io/instance: ingress-nginx
    549. app.kubernetes.io/version: 0.32.0
    550. app.kubernetes.io/managed-by: Helm
    551. app.kubernetes.io/component: admission-webhook
    552. namespace: ingress-nginx
    553. roleRef:
    554. apiGroup: rbac.authorization.k8s.io
    555. kind: ClusterRole
    556. name: ingress-nginx-admission
    557. subjects:
    558. - kind: ServiceAccount
    559. name: ingress-nginx-admission
    560. namespace: ingress-nginx
    561. ---
    562. # Source: ingress-nginx/templates/admission-webhooks/job-patch/job-createSecret.yaml
    563. apiVersion: batch/v1
    564. kind: Job
    565. metadata:
    566. name: ingress-nginx-admission-create
    567. annotations:
    568. helm.sh/hook: pre-install,pre-upgrade
    569. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    570. labels:
    571. helm.sh/chart: ingress-nginx-2.0.3
    572. app.kubernetes.io/name: ingress-nginx
    573. app.kubernetes.io/instance: ingress-nginx
    574. app.kubernetes.io/version: 0.32.0
    575. app.kubernetes.io/managed-by: Helm
    576. app.kubernetes.io/component: admission-webhook
    577. namespace: ingress-nginx
    578. spec:
    579. template:
    580. metadata:
    581. name: ingress-nginx-admission-create
    582. labels:
    583. helm.sh/chart: ingress-nginx-2.0.3
    584. app.kubernetes.io/name: ingress-nginx
    585. app.kubernetes.io/instance: ingress-nginx
    586. app.kubernetes.io/version: 0.32.0
    587. app.kubernetes.io/managed-by: Helm
    588. app.kubernetes.io/component: admission-webhook
    589. spec:
    590. containers:
    591. - name: create
    592. image: jettech/kube-webhook-certgen:v1.2.0
    593. imagePullPolicy: IfNotPresent
    594. args:
    595. - create
    596. - --host=ingress-nginx-controller-admission,ingress-nginx-controller-admission.ingress-nginx.svc
    597. - --namespace=ingress-nginx
    598. - --secret-name=ingress-nginx-admission
    599. restartPolicy: OnFailure
    600. serviceAccountName: ingress-nginx-admission
    601. securityContext:
    602. runAsNonRoot: true
    603. runAsUser: 2000
    604. ---
    605. # Source: ingress-nginx/templates/admission-webhooks/job-patch/job-patchWebhook.yaml
    606. apiVersion: batch/v1
    607. kind: Job
    608. metadata:
    609. name: ingress-nginx-admission-patch
    610. annotations:
    611. helm.sh/hook: post-install,post-upgrade
    612. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    613. labels:
    614. helm.sh/chart: ingress-nginx-2.0.3
    615. app.kubernetes.io/name: ingress-nginx
    616. app.kubernetes.io/instance: ingress-nginx
    617. app.kubernetes.io/version: 0.32.0
    618. app.kubernetes.io/managed-by: Helm
    619. app.kubernetes.io/component: admission-webhook
    620. namespace: ingress-nginx
    621. spec:
    622. template:
    623. metadata:
    624. name: ingress-nginx-admission-patch
    625. labels:
    626. helm.sh/chart: ingress-nginx-2.0.3
    627. app.kubernetes.io/name: ingress-nginx
    628. app.kubernetes.io/instance: ingress-nginx
    629. app.kubernetes.io/version: 0.32.0
    630. app.kubernetes.io/managed-by: Helm
    631. app.kubernetes.io/component: admission-webhook
    632. spec:
    633. containers:
    634. - name: patch
    635. image: jettech/kube-webhook-certgen:v1.2.0
    636. imagePullPolicy:
    637. args:
    638. - patch
    639. - --webhook-name=ingress-nginx-admission
    640. - --namespace=ingress-nginx
    641. - --patch-mutating=false
    642. - --secret-name=ingress-nginx-admission
    643. - --patch-failure-policy=Fail
    644. restartPolicy: OnFailure
    645. serviceAccountName: ingress-nginx-admission
    646. securityContext:
    647. runAsNonRoot: true
    648. runAsUser: 2000
    649. ---
    650. # Source: ingress-nginx/templates/admission-webhooks/job-patch/role.yaml
    651. apiVersion: rbac.authorization.k8s.io/v1
    652. kind: Role
    653. metadata:
    654. name: ingress-nginx-admission
    655. annotations:
    656. helm.sh/hook: pre-install,pre-upgrade,post-install,post-upgrade
    657. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    658. labels:
    659. helm.sh/chart: ingress-nginx-2.0.3
    660. app.kubernetes.io/name: ingress-nginx
    661. app.kubernetes.io/instance: ingress-nginx
    662. app.kubernetes.io/version: 0.32.0
    663. app.kubernetes.io/managed-by: Helm
    664. app.kubernetes.io/component: admission-webhook
    665. namespace: ingress-nginx
    666. rules:
    667. - apiGroups:
    668. - ''
    669. resources:
    670. - secrets
    671. verbs:
    672. - get
    673. - create
    674. ---
    675. # Source: ingress-nginx/templates/admission-webhooks/job-patch/rolebinding.yaml
    676. apiVersion: rbac.authorization.k8s.io/v1
    677. kind: RoleBinding
    678. metadata:
    679. name: ingress-nginx-admission
    680. annotations:
    681. helm.sh/hook: pre-install,pre-upgrade,post-install,post-upgrade
    682. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    683. labels:
    684. helm.sh/chart: ingress-nginx-2.0.3
    685. app.kubernetes.io/name: ingress-nginx
    686. app.kubernetes.io/instance: ingress-nginx
    687. app.kubernetes.io/version: 0.32.0
    688. app.kubernetes.io/managed-by: Helm
    689. app.kubernetes.io/component: admission-webhook
    690. namespace: ingress-nginx
    691. roleRef:
    692. apiGroup: rbac.authorization.k8s.io
    693. kind: Role
    694. name: ingress-nginx-admission
    695. subjects:
    696. - kind: ServiceAccount
    697. name: ingress-nginx-admission
    698. namespace: ingress-nginx
    699. ---
    700. # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml
    701. apiVersion: v1
    702. kind: ServiceAccount
    703. metadata:
    704. name: ingress-nginx-admission
    705. annotations:
    706. helm.sh/hook: pre-install,pre-upgrade,post-install,post-upgrade
    707. helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    708. labels:
    709. helm.sh/chart: ingress-nginx-2.0.3
    710. app.kubernetes.io/name: ingress-nginx
    711. app.kubernetes.io/instance: ingress-nginx
    712. app.kubernetes.io/version: 0.32.0
    713. app.kubernetes.io/managed-by: Helm
    714. app.kubernetes.io/component: admission-webhook
    715. namespace: ingress-nginx

    https://www.jb51.net/article/183828.htm