-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update guardrails controller and guardrails controller test
- Loading branch information
1 parent
b2fdcc9
commit 69b72fd
Showing
36 changed files
with
2,980 additions
and
928 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
ARG UBI_MINIMAL_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal | ||
ARG UBI_BASE_IMAGE_TAG=latest | ||
ARG PROTOC_VERSION=26.0 | ||
ARG CONFIG_FILE=config/config.yaml | ||
|
||
## Rust builder ################################################################ | ||
# Specific debian version so that compatible glibc version is used | ||
FROM rust:1.80.1-bullseye as rust-builder | ||
ARG PROTOC_VERSION | ||
|
||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | ||
|
||
# Install protoc, no longer included in prost crate | ||
RUN cd /tmp && \ | ||
curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ | ||
unzip protoc-*.zip -d /usr/local && rm protoc-*.zip | ||
|
||
WORKDIR /app | ||
|
||
COPY rust-toolchain.toml rust-toolchain.toml | ||
|
||
RUN rustup component add rustfmt | ||
|
||
## Orchestrator builder ######################################################### | ||
FROM rust-builder as fms-guardrails-orchestr8-builder | ||
|
||
COPY build.rs *.toml LICENSE /app/ | ||
COPY ${CONFIG_FILE} /app/config/config.yaml | ||
COPY protos/ /app/protos/ | ||
COPY src/ /app/src/ | ||
|
||
WORKDIR /app | ||
|
||
# TODO: Make releases via cargo-release | ||
RUN cargo install --root /app/ --path . | ||
|
||
## Tests stage ################################################################## | ||
FROM fms-guardrails-orchestr8-builder as tests | ||
RUN cargo test | ||
|
||
## Lint stage ################################################################### | ||
FROM fms-guardrails-orchestr8-builder as lint | ||
RUN cargo clippy --all-targets --all-features -- -D warnings | ||
|
||
## Formatting check stage ####################################################### | ||
FROM fms-guardrails-orchestr8-builder as format | ||
RUN cargo fmt --check | ||
|
||
## Release Image ################################################################ | ||
|
||
FROM ${UBI_MINIMAL_BASE_IMAGE}:${UBI_BASE_IMAGE_TAG} as fms-guardrails-orchestr8-release | ||
|
||
COPY --from=fms-guardrails-orchestr8-builder /app/bin/ /app/bin/ | ||
COPY ${CONFIG_FILE} /app/config/config.yaml | ||
|
||
RUN microdnf install -y --disableplugin=subscription-manager shadow-utils compat-openssl11 && \ | ||
microdnf clean all --disableplugin=subscription-manager | ||
|
||
RUN groupadd --system orchestr8 --gid 1001 && \ | ||
adduser --system --uid 1001 --gid 0 --groups orchestr8 \ | ||
--create-home --home-dir /app --shell /sbin/nologin \ | ||
--comment "FMS Orchestrator User" orchestr8 | ||
|
||
USER orchestr8 | ||
|
||
ENV ORCHESTRATOR_CONFIG /app/config/config.yaml | ||
|
||
CMD /app/bin/fms-guardrails-orchestr8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
Copyright 2023. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
type TLSSpec struct { | ||
Type string `json:"type"` | ||
CertPath string `json:"cert_path"` | ||
KeyPath string `json:"key_path"` | ||
CACertPath string `json:"ca_cert_path"` | ||
} | ||
|
||
type ServiceSpec struct { | ||
Hostname string `json:"hostname"` | ||
Port int `json:"port"` | ||
TLS TLSSpec `json:"tls"` | ||
} | ||
|
||
type GeneratorSpec struct { | ||
Provider string `json:"provider"` | ||
Service ServiceSpec `json:"service"` | ||
} | ||
|
||
type ChunkerSpec struct { | ||
Provider string `json:"provider"` | ||
Service ServiceSpec `json:"service"` | ||
} | ||
|
||
type DetectorSpec struct { | ||
Type string `json:"type"` | ||
Service ServiceSpec `json:"service"` | ||
ChunkerName string `json:"chunkerName"` | ||
DefaultThreshold string `json:"defaultThreshold"` | ||
} | ||
|
||
// GuardrailsOrchestratorSpec defines the desired state of GuardrailsOrchestrator. | ||
type GuardrailsOrchestratorSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// Number of replicas | ||
Replicas int32 `json:"replicas"` | ||
// Generator configuration | ||
Generator GeneratorSpec `json:"generator"` | ||
// Chunker configuration | ||
Chunkers []ChunkerSpec `json:"chunker"` | ||
// Detector configuration | ||
Detectors []DetectorSpec `json:"detectors"` | ||
// TLS configuration | ||
TLS string `json:"tls"` | ||
} | ||
|
||
// GuardrailsOrchestratorStatus defines the observed state of GuardrailsOrchestrator. | ||
type GuardrailsOrchestratorStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Condition string `json:"condition,omitempty"` | ||
Ready bool `json:"ready"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// GuardrailsOrchestrator is the Schema for the guardrailsorchestrators API. | ||
type GuardrailsOrchestrator struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec GuardrailsOrchestratorSpec `json:"spec,omitempty"` | ||
Status GuardrailsOrchestratorStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// GuardrailsOrchestratorList contains a list of GuardrailsOrchestrator. | ||
type GuardrailsOrchestratorList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []GuardrailsOrchestrator `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&GuardrailsOrchestrator{}, &GuardrailsOrchestratorList{}) | ||
} |
Oops, something went wrong.