mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
updates
This commit is contained in:
64
src/bootstrap/namespaces/namespaces.ts
Normal file
64
src/bootstrap/namespaces/namespaces.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { NamespaceInstance } from '../../instances/namespace.ts';
|
||||
import type { Services } from '../../utils/service.ts';
|
||||
import { ResourceService } from '../../services/resources/resources.ts';
|
||||
|
||||
class NamespaceService {
|
||||
#homelab: NamespaceInstance;
|
||||
#istioSystem: NamespaceInstance;
|
||||
#certManager: NamespaceInstance;
|
||||
|
||||
constructor(services: Services) {
|
||||
const resourceService = services.get(ResourceService);
|
||||
this.#homelab = resourceService.getInstance(
|
||||
{
|
||||
apiVersion: 'v1',
|
||||
kind: 'Namespace',
|
||||
name: 'homelab',
|
||||
},
|
||||
NamespaceInstance,
|
||||
);
|
||||
this.#istioSystem = resourceService.getInstance(
|
||||
{
|
||||
apiVersion: 'v1',
|
||||
kind: 'Namespace',
|
||||
name: 'istio-system',
|
||||
},
|
||||
NamespaceInstance,
|
||||
);
|
||||
this.#certManager = resourceService.getInstance(
|
||||
{
|
||||
apiVersion: 'v1',
|
||||
kind: 'Namespace',
|
||||
name: 'cert-manager',
|
||||
},
|
||||
NamespaceInstance,
|
||||
);
|
||||
this.#homelab.on('changed', this.ensure);
|
||||
this.#istioSystem.on('changed', this.ensure);
|
||||
this.#certManager.on('changed', this.ensure);
|
||||
}
|
||||
|
||||
public get homelab() {
|
||||
return this.#homelab;
|
||||
}
|
||||
public get istioSystem() {
|
||||
return this.#istioSystem;
|
||||
}
|
||||
public get certManager() {
|
||||
return this.#certManager;
|
||||
}
|
||||
|
||||
public ensure = async () => {
|
||||
await this.#homelab.ensure({
|
||||
metadata: {
|
||||
labels: {
|
||||
'istio-injection': 'enabled',
|
||||
},
|
||||
},
|
||||
});
|
||||
await this.#istioSystem.ensure({});
|
||||
await this.#certManager.ensure({});
|
||||
};
|
||||
}
|
||||
|
||||
export { NamespaceService };
|
||||
Reference in New Issue
Block a user