File tree 5 files changed +157
-3
lines changed
5 files changed +157
-3
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,13 @@ ARG ATLAS_VERSION=latest
46
46
ENV ATLAS_VERSION=${ATLAS_VERSION}
47
47
RUN curl -sSf https://atlasgo.sh | sh
48
48
49
+ FROM docker:27.3.1-cli-alpine3.20 as docker
50
+
49
51
FROM alpine:3.20
52
+ ENV ATLAS_KUBERNETES_OPERATOR=1
50
53
WORKDIR /
51
- COPY --from=builder /workspace/manager .
52
54
COPY --from=atlas /usr/local/bin/atlas /usr/local/bin
53
- RUN chmod +x /usr/local/bin/atlas
54
- ENV ATLAS_KUBERNETES_OPERATOR=1
55
+ COPY --from=docker /usr/local/bin/docker /usr/local/bin
56
+ COPY --from=builder /workspace/manager .
55
57
USER 65532:65532
56
58
ENTRYPOINT ["/manager" ]
Original file line number Diff line number Diff line change
1
+ # Copyright 2023 The Atlas Operator Authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ namespace : atlas-operator-system
16
+ apiVersion : kustomize.config.k8s.io/v1beta1
17
+ kind : Kustomization
18
+ resources :
19
+ - ../default
20
+ patches :
21
+ - target :
22
+ kind : Deployment
23
+ namespace : system
24
+ name : controller-manager
25
+ patch : |-
26
+ - op: add
27
+ path: "/spec/template/spec/containers/0/env/-"
28
+ value:
29
+ name: DOCKER_HOST
30
+ value: "unix:///run/user/1000/docker.sock"
31
+ - op: add
32
+ path: "/spec/template/spec/containers/0/volumeMounts/-"
33
+ value:
34
+ name: dind-sock
35
+ mountPath: /run/user
36
+ - op: add
37
+ path: "/spec/template/spec/containers/-"
38
+ value:
39
+ name: dind
40
+ image: docker:27.3.1-dind-rootless
41
+ securityContext:
42
+ privileged: true
43
+ runAsGroup: 1000
44
+ runAsUser: 1000
45
+ volumeMounts:
46
+ - name: dind-sock
47
+ mountPath: /run/user
48
+ - op: add
49
+ path: "/spec/template/spec/volumes/-"
50
+ value:
51
+ name: dind-sock
52
+ emptyDir: {}
Original file line number Diff line number Diff line change @@ -114,5 +114,7 @@ spec:
114
114
requests :
115
115
cpu : 10m
116
116
memory : 64Mi
117
+ volumeMounts : []
117
118
serviceAccountName : controller-manager
118
119
terminationGracePeriodSeconds : 10
120
+ volumes : []
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ profiles:
30
30
paths :
31
31
- config/default
32
32
- config/sqlserver
33
+ - config/dind
33
34
- name : helm
34
35
deploy :
35
36
helm :
Original file line number Diff line number Diff line change
1
+ env DB_URL=postgres://root:pass@postgres.${NAMESPACE}:5432/postgres?sslmode=disable
2
+ kubectl apply -f database.yaml
3
+ kubectl create secret generic postgres-credentials --from-literal=url=${DB_URL}
4
+ # Wait for the DB ready before creating the schema
5
+ kubectl wait --for=condition=ready --timeout=60s -l app=postgres pods
6
+
7
+ # Create the schema
8
+ kubectl apply -f schema.yaml
9
+ kubectl wait --for=condition=ready --timeout=360s AtlasSchema/atlasschema-postgres
10
+
11
+ # Inspect the schema to ensure it's correct
12
+ atlas schema inspect -u ${DB_URL}
13
+ cmp stdout schema.hcl
14
+ -- schema.hcl --
15
+ table "users2" {
16
+ schema = schema.public
17
+ column "id" {
18
+ null = false
19
+ type = integer
20
+ }
21
+ primary_key {
22
+ columns = [column.id]
23
+ }
24
+ }
25
+ schema "public" {
26
+ comment = "standard public schema"
27
+ }
28
+ -- schema.yaml --
29
+ apiVersion: db.atlasgo.io/v1alpha1
30
+ kind: AtlasSchema
31
+ metadata:
32
+ name: atlasschema-postgres
33
+ spec:
34
+ devURL: docker://postgres/15/dev
35
+ urlFrom:
36
+ secretKeyRef:
37
+ name: postgres-credentials
38
+ key: url
39
+ schema:
40
+ sql: |
41
+ create table users2 (
42
+ id int not null,
43
+ primary key (id)
44
+ );
45
+ -- database.yaml --
46
+ apiVersion: v1
47
+ kind: Service
48
+ metadata:
49
+ name: postgres
50
+ spec:
51
+ selector:
52
+ app: postgres
53
+ ports:
54
+ - name: postgres
55
+ port: 5432
56
+ targetPort: postgres
57
+ type: ClusterIP
58
+ ---
59
+ apiVersion: apps/v1
60
+ kind: Deployment
61
+ metadata:
62
+ name: postgres
63
+ spec:
64
+ selector:
65
+ matchLabels:
66
+ app: postgres
67
+ replicas: 1
68
+ template:
69
+ metadata:
70
+ labels:
71
+ app: postgres
72
+ spec:
73
+ securityContext:
74
+ runAsNonRoot: true
75
+ runAsUser: 999
76
+ containers:
77
+ - name: postgres
78
+ image: postgres:15.4
79
+ securityContext:
80
+ allowPrivilegeEscalation: false
81
+ capabilities:
82
+ drop:
83
+ - all
84
+ env:
85
+ - name: POSTGRES_PASSWORD
86
+ value: pass
87
+ - name: POSTGRES_USER
88
+ value: root
89
+ ports:
90
+ - containerPort: 5432
91
+ name: postgres
92
+ readinessProbe:
93
+ initialDelaySeconds: 5
94
+ periodSeconds: 2
95
+ timeoutSeconds: 1
96
+ exec:
97
+ command: [ "pg_isready" ]
You can’t perform that action at this time.
0 commit comments