diff --git a/samples/sql-input/README.md b/samples/sql-input/README.md deleted file mode 100644 index 85a5661..0000000 --- a/samples/sql-input/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# SQL Input Tool - -## Quick Start - -A setup script is included to create the postgres database in SQL and load a preconfigured SQL script. An example usage of the setup script would be as follows: - -```sh -# ./setup.sh $K8S_NAMESPACE $DB_NAME $DB_USERNAME $DB_PASSWORD $LOCAL_SQL_FILE_PATH -./setup.sh azure-iot-operations database username password ./initialization.sql -``` diff --git a/samples/sql-input/initialization.sql b/samples/sql-input/initialization.sql deleted file mode 100644 index 09131d5..0000000 --- a/samples/sql-input/initialization.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Copyright (c) Microsoft Corporation. --- Licensed under the MIT License. - -CREATE TABLE assetinfo ( - assetID varchar(255), - serialNumber varchar(255), - name varchar(255), - site varchar(255), - maintenanceStatus varchar(255) -); - - -INSERT INTO assetinfo (assetID, serialNumber, name, site, maintenanceStatus) -VALUES -('Sea_O1', 'SN001', 'Contoso', 'Seattle', 'Done'), -('Red_O1', 'SN002', 'Contoso', 'Redmond', 'Upcoming'), -('Tac_O1', 'SN003', 'Contoso', 'Tacoma', 'Overdue'), -('Sea_S1', 'SN004', 'Contoso', 'Seattle', 'Done'), -('Red_S1', 'SN005', 'Contoso', 'Redmond', 'Upcoming'), -('Tac_O1', 'SN006', 'Contoso', 'Tacoma', 'Overdue'), -('Sea_M1', 'SN007', 'Contoso', 'Seattle', 'Done'), -('Red_M1', 'SN008', 'Contoso', 'Redmond', 'Upcoming'), -('Tac_M1', 'SN009', 'Contoso', 'Tacoma', 'Overdue'), -('Tac_S1', 'SN010', 'Contoso', 'Tacoma', 'Upcoming'); \ No newline at end of file diff --git a/samples/sql-input/manifest.yml b/samples/sql-input/manifest.yml deleted file mode 100644 index bc03983..0000000 --- a/samples/sql-input/manifest.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- -kind: PersistentVolume -apiVersion: v1 -metadata: - namespace: azure-iot-operations - name: pg-pv - labels: - app: postgres - type: local -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/mnt/data" ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - namespace: azure-iot-operations - name: pg-pvc - labels: - app: postgres -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi ---- -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: azure-iot-operations - name: pg-config - labels: - app: postgres -data: - POSTGRES_DB: database - POSTGRES_USER: username - POSTGRES_PASSWORD: password ---- -apiVersion: v1 -kind: Service -metadata: - namespace: azure-iot-operations - name: pg-svc - labels: - app: postgres -spec: - ports: - - port: 5432 - name: postgres - type: NodePort - selector: - app: postgres ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - namespace: azure-iot-operations - name: pg-statefulset - labels: - app: postgres -spec: - serviceName: "postgres" - replicas: 1 - selector: - matchLabels: - app: postgres - template: - metadata: - labels: - app: postgres - spec: - containers: - - name: postgres - image: mcr.microsoft.com/cbl-mariner/base/postgres:14 - envFrom: - - configMapRef: - name: pg-config - ports: - - containerPort: 5432 - volumeMounts: - - name: pv-data - mountPath: /var/lib/postgresql/data - volumes: - - name: pv-data - persistentVolumeClaim: - claimName: pg-pvc diff --git a/samples/sql-input/setup.sh b/samples/sql-input/setup.sh deleted file mode 100755 index 3a19183..0000000 --- a/samples/sql-input/setup.sh +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -# Create manifest file. -cat << EOF > manifest.yml ---- -kind: PersistentVolume -apiVersion: v1 -metadata: - namespace: $1 - name: pg-pv - labels: - app: postgres - type: local -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/mnt/data" ---- -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - namespace: $1 - name: pg-pvc - labels: - app: postgres -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi ---- -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: $1 - name: pg-config - labels: - app: postgres -data: - POSTGRES_DB: $2 - POSTGRES_USER: $3 - POSTGRES_PASSWORD: $4 ---- -apiVersion: v1 -kind: Service -metadata: - namespace: $1 - name: pg-svc - labels: - app: postgres -spec: - ports: - - port: 5432 - name: postgres - type: NodePort - selector: - app: postgres ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - namespace: $1 - name: pg-statefulset - labels: - app: postgres -spec: - serviceName: "postgres" - replicas: 1 - selector: - matchLabels: - app: postgres - template: - metadata: - labels: - app: postgres - spec: - containers: - - name: postgres - image: mcr.microsoft.com/cbl-mariner/base/postgres:14 - envFrom: - - configMapRef: - name: pg-config - ports: - - containerPort: 5432 - volumeMounts: - - name: pv-data - mountPath: /var/lib/postgresql/data - volumes: - - name: pv-data - persistentVolumeClaim: - claimName: pg-pvc -EOF - -# Delete resources from kubernetes if one already exists. -kubectl delete -f manifest.yml - -# Apply newly created kubernetes manifest. -kubectl apply -f manifest.yml - -# Wait for sql pod to be ready. -kubectl wait --for=condition=ready --namespace $1 pod/pg-statefulset-0 - -# Cat contents of SQL script into psql exec on new SQL pod. -cat $5 | kubectl exec -it --namespace $1 pg-statefulset-0 -- psql postgresql://$3:$4@localhost:5432/$2 -