Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cue-lang 入門 #75

Open
suzuki-shunsuke opened this issue Nov 23, 2021 · 3 comments
Open

cue-lang 入門 #75

suzuki-shunsuke opened this issue Nov 23, 2021 · 3 comments
Labels

Comments

@suzuki-shunsuke
Copy link
Owner

Data Validation: https://cuelang.org/docs/usecases/validation/

@suzuki-shunsuke
Copy link
Owner Author

cue から YAML を生成

$ cue export --out yaml input.cue

@suzuki-shunsuke
Copy link
Owner Author

k8s manifest を cue で抽象化したい

まずは deployment を簡単にラップしたい。

$ kubectl create deploy --dry-run=client -o yaml --image=nginx --replicas=3 app > deployment.yaml

timestamp とかを消す

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: app
  name: app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
      - image: nginx
        name: nginx

cue に変換する

$ cue import deployment.yaml

deployment.cue が生成される

apiVersion: "apps/v1"
kind:       "Deployment"
metadata: {
	labels: app: "app"
	name: "app"
}
spec: {
	replicas: 3
	selector: matchLabels: app: "app"
	template: {
		metadata: labels: app: "app"
		spec: containers: [{
			image: "nginx"
			name:  "nginx"
		}]
	}
}

cue から yaml を生成する

$ cue export --out yaml deployment.cue

ここから deployment.cue を書き換えていく。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

No branches or pull requests

1 participant