Skip to content

Commit

Permalink
add clusterip service helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
dianabarsan committed Mar 29, 2024
1 parent c641ff3 commit cebb389
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
18 changes: 18 additions & 0 deletions tests/helm/templates/api-clusterip-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: ingress-nginx-4.0.1
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx-controller-admission
spec:
type: ClusterIP
ports:
- name: https-webhook
port: 443
targetPort: webhook
appProtocol: https
2 changes: 2 additions & 0 deletions tests/helm/templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ spec:
name: cht-api
ports:
- containerPort: 5988
port: 5988
targetPort: 5988
resources: {}
restartPolicy: Always
status: {}
20 changes: 13 additions & 7 deletions tests/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const request = (options, { debug } = {}) => { //NOSONAR

return rpn(options).catch(err => {
err.responseBody = err?.response?.body;
console.warn(`Error with request: ${options.method || 'GET'} ${options.uri}`);
console.warn(`Error with request: ${options.method || 'GET'} ${options.uri} ${err.status} ${err.responseBody}`);
throw err;
});
};
Expand Down Expand Up @@ -1057,15 +1057,13 @@ const runCommand = (command) => {
proc.stdout.on('data', log);
proc.stderr.on('data', log);

proc.on('close', () => resolve(output));
proc.on('close', (number) => number ? reject(output) : resolve(output));
});
};

const createCluster = async (dataDir) => {
await runCommand('kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/' +
'controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml --validate=false');
await runCommand(
`k3d cluster create --port 443:443@loadbalancer --port 80:80@loadbalancer --volume ${dataDir}:/data`
`k3d cluster create ${PROJECT_NAME} --api-port 6550 --port 443:443@loadbalancer --volume ${dataDir}:/data`
);
};

Expand All @@ -1077,6 +1075,15 @@ const importImages = async () => {
}
};

const cleanupOldCluster = async () => {
try {
await runCommand(`helm uninstall ${PROJECT_NAME} -n ${PROJECT_NAME}`);
await runCommand(`k3d cluster delete ${PROJECT_NAME}`);
} catch (err) {
// ignore
}
};

const prepK3DServices = async (defaultSettings) => {
infrastructure = 'k3d';
await createLogDir();
Expand All @@ -1087,8 +1094,7 @@ const prepK3DServices = async (defaultSettings) => {
await fs.promises.mkdir(path.join(dataDir, 'srv2'));
await fs.promises.mkdir(path.join(dataDir, 'srv3'));

await runCommand(`helm uninstall ${PROJECT_NAME} -n ${PROJECT_NAME}`);
await runCommand('k3d cluster delete');
await cleanupOldCluster();
await createCluster(dataDir);
await importImages();

Expand Down

0 comments on commit cebb389

Please sign in to comment.