Kubernetes kustomize: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is. | Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is. | ||
== Basic == | |||
Kustomize is a standalone tool to customize Kubernetes objects through a kustomization file. | |||
Since 1.14, Kubectl also supports the management of Kubernetes objects using a kustomization file. To view Resources found in a directory containing a kustomization file, run the following command. | |||
<pre> | |||
$ kubectl kustomize <kustomization_directory> | |||
$ kubectl kustomize ./k8s | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
labels: | |||
app: simple-golang | |||
name: svc-cluster-simple-golang | |||
spec: | |||
ports: | |||
- name: http | |||
port: 8090 | |||
protocol: TCP | |||
targetPort: 8090 | |||
selector: | |||
app: simple-golang | |||
type: ClusterIP | |||
--- | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
labels: | |||
app: simple-golang | |||
name: svc-nodeport-simple-golang | |||
spec: | |||
ports: | |||
- port: 8090 | |||
protocol: TCP | |||
selector: | |||
app: simple-golang | |||
type: NodePort | |||
--- | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
labels: | |||
app: simple-golang | |||
name: simple-golang | |||
spec: | |||
replicas: 1 | |||
selector: | |||
matchLabels: | |||
app: simple-golang | |||
template: | |||
metadata: | |||
labels: | |||
app: simple-golang | |||
deployment: simple-golang | |||
spec: | |||
containers: | |||
- image: simple_golang_k8s:latest | |||
name: simple-golang | |||
ports: | |||
- containerPort: 8090 | |||
resources: | |||
limits: | |||
cpu: "1" | |||
memory: 256M | |||
requests: | |||
cpu: 100m | |||
memory: 128M | |||
--- | |||
apiVersion: extensions/v1beta1 | |||
kind: Ingress | |||
metadata: | |||
labels: | |||
app: simple-golang | |||
name: ingress-simple-golang | |||
spec: | |||
backend: | |||
serviceName: svc-nodeport-simple-golang | |||
servicePort: 8090 | |||
rules: | |||
- host: foo.mydomain.com | |||
http: | |||
paths: | |||
- backend: | |||
serviceName: svc-nodeport-simple-golang | |||
servicePort: 8090 | |||
</pre> | |||
To apply those Resources, run '''kubectl apply''' with --kustomize or -k flag. | |||
<pre> | |||
$ kubectl apply -k <kustomization_directory> | |||
</pre> | |||
== See also == | == See also == |
Revision as of 15:04, 20 February 2020
Overview
Kustomize 내용 정리.
Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is.
Basic
Kustomize is a standalone tool to customize Kubernetes objects through a kustomization file.
Since 1.14, Kubectl also supports the management of Kubernetes objects using a kustomization file. To view Resources found in a directory containing a kustomization file, run the following command.
$ kubectl kustomize <kustomization_directory> $ kubectl kustomize ./k8s apiVersion: v1 kind: Service metadata: labels: app: simple-golang name: svc-cluster-simple-golang spec: ports: - name: http port: 8090 protocol: TCP targetPort: 8090 selector: app: simple-golang type: ClusterIP --- apiVersion: v1 kind: Service metadata: labels: app: simple-golang name: svc-nodeport-simple-golang spec: ports: - port: 8090 protocol: TCP selector: app: simple-golang type: NodePort --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: simple-golang name: simple-golang spec: replicas: 1 selector: matchLabels: app: simple-golang template: metadata: labels: app: simple-golang deployment: simple-golang spec: containers: - image: simple_golang_k8s:latest name: simple-golang ports: - containerPort: 8090 resources: limits: cpu: "1" memory: 256M requests: cpu: 100m memory: 128M --- apiVersion: extensions/v1beta1 kind: Ingress metadata: labels: app: simple-golang name: ingress-simple-golang spec: backend: serviceName: svc-nodeport-simple-golang servicePort: 8090 rules: - host: foo.mydomain.com http: paths: - backend: serviceName: svc-nodeport-simple-golang servicePort: 8090
To apply those Resources, run kubectl apply with --kustomize or -k flag.
$ kubectl apply -k <kustomization_directory>
See also
- https://blog.stack-labs.com/code/kustomize-101/ - Kustomize - The right way to do templating in Kubernetes