Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt committed Apr 24, 2023
2 parents 09ade1a + 570d00d commit a8c6e07
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/region-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Users can work on Onyxia as a User or as a Group to which they belong. Each user
| --------------------- | ------- | ------------------------------------------------------------------ | ---- |
| `type` | | Type of the platform on which services are launched. Only Kubernetes is supported, Marathon has been removed. | "KUBERNETES" |
| `allowNamespaceCreation` | true | If true, the /onboarding endpoint is enabled and the user will have a namespace created on its first request on a service resource. | true |
| `namespaceLabels` | | Labels to add at namespace creation | {"zone":"prod"} |
| `namespaceAnnotations` | | Annotations to add at namespace creation | {"zone":"prod"} |
| `singleNamespace` | true | When true, all users share the same namespace on the service provider. This configuration can be used if a project works on its own Onyxia region. | |
| `userNamespace` | true | When true, all users have a namespace for their work. This configuration can be used if you don't allow a user to have their own space to work and only use project space | |
| `namespacePrefix` | "user-" | User has a personal namespace like namespacePrefix + userId (should only be used when not singleNamespace but not the case) | |
Expand Down Expand Up @@ -99,7 +101,7 @@ When this feature is enabled, namespaces are created with **quotas**.
| --------------------- | ------- | ------------------------------------------------------------------ |
| `enabled` | false | Whether or not users are subject to a resource limitation. Quotas can only be applied to users and not to groups. |
| `allowUserModification` | true | Whether or not the user can manually disable or change its own limitation. |
| `defaultQuota` | | The quota is applied on the namespace before user modification or reset. |
| `default` | | The quota is applied on the namespace at creation, before user modification or reset. New configuration will not be applied to existing namespaces. |

A quota follows the Kubernetes model which is composed of:
"requests.memory"
Expand Down
15 changes: 10 additions & 5 deletions onyxia-api/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/bin/bash

# Import CA certificates to Java keystore
for file in $CACERTS_DIR/*
do
echo "Adding $file to keystore"
keytool -import -cacerts -trustcacerts -noprompt -storepass changeit -alias $(basename $file) -file $file
done
if [[ -n "$CACERTS_DIR" ]]; then
for file in $CACERTS_DIR/*
do
if [ -f "$file" ]
then
echo "Adding $file to keystore"
keytool -import -cacerts -trustcacerts -noprompt -storepass changeit -alias $(basename $file) -file $file
fi
done
fi

# Run application
java -jar /app.jar
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private Service getServiceFromRelease(
KubernetesClient client = kubernetesClientProvider.getUserClient(region, user);
InputStream inputStream =
new ByteArrayInputStream(manifest.getBytes(Charset.forName("UTF-8")));
List<HasMetadata> hasMetadatas = client.load(inputStream).get();
List<HasMetadata> hasMetadatas = client.load(inputStream).items();
List<Ingress> ingresses =
hasMetadatas.stream()
.filter(hasMetadata -> hasMetadata instanceof Ingress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ private String createNamespace(Region region, String namespaceId, Owner owner) {
new NamespaceBuilder()
.withNewMetadata()
.withName(namespaceId)
.withLabels(region.getServices().getNamespaceLabels())
.addToLabels("onyxia_owner", owner.getId())
.withAnnotations(region.getServices().getNamespaceAnnotations())
.endMetadata()
.build())
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import fr.insee.onyxia.model.service.quota.Quota;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Schema(description = "")
public class Region {
Expand Down Expand Up @@ -183,6 +185,8 @@ public static enum AuthenticationMode {
private Service.ServiceType type;
private boolean singleNamespace = true;
private boolean allowNamespaceCreation = true;
private Map<String, String> namespaceLabels = new HashMap<String, String>();
private Map<String, String> namespaceAnnotations = new HashMap<String, String>();
private boolean userNamespace = true;
private String namespacePrefix = "user-";
private String groupNamespacePrefix = "projet-";
Expand Down Expand Up @@ -508,6 +512,22 @@ public void setAllowNamespaceCreation(boolean allowNamespaceCreation) {
this.allowNamespaceCreation = allowNamespaceCreation;
}

public Map<String, String> getNamespaceLabels() {
return namespaceLabels;
}

public void getNamespaceLabels(Map<String, String> namespaceLabels) {
this.namespaceLabels = namespaceLabels;
}

public Map<String, String> getNamespaceAnnotations() {
return namespaceAnnotations;
}

public void getNamespaceAnnotations(Map<String, String> namespaceAnnotations) {
this.namespaceAnnotations = namespaceAnnotations;
}

public boolean isUserNamespace() {
return userNamespace;
}
Expand Down

0 comments on commit a8c6e07

Please sign in to comment.