Skip to content

Commit

Permalink
Make changes in pipeline-service to install workspace controller
Browse files Browse the repository at this point in the history
  • Loading branch information
bnallapeta authored and Roming22 committed Oct 19, 2022
1 parent c55316a commit 037effa
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 29 deletions.
29 changes: 0 additions & 29 deletions ckcp/openshift_dev_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -404,35 +404,6 @@ register_compute() {
--crs-to-sync "$(IFS=,; echo "${CRS_TO_SYNC[*]}")" |
indent 4

check_cr_sync
}

check_cr_sync() {
# Wait until CRDs are synced to KCP
echo -n "- Sync CRDs to KCP: "
local cr_regexp
cr_regexp="$(
IFS=\|
echo "${CRS_TO_SYNC[*]}"
)"
local wait_period=0
while [[ "$(KUBECONFIG="$KUBECONFIG_KCP" kubectl api-resources -o name 2>&1 | grep -Ewc "$cr_regexp")" -ne ${#CRS_TO_SYNC[@]} ]]; do
wait_period=$((wait_period + 10))
#when timeout, print out the CR resoures that is not synced to KCP
if [ "$wait_period" -gt 300 ]; then
echo "Failed to sync following resources to KCP: "
cr_synced=$(KUBECONFIG="$KUBECONFIG_KCP" kubectl api-resources -o name)
for cr in "${CRS_TO_SYNC[@]}"; do
if [ "$(echo "$cr_synced" | grep -wc "$cr")" -eq 0 ]; then
echo " * $cr"
fi
done
exit 1
fi
echo -n "."
sleep 10
done
echo "OK"
}

main() {
Expand Down
6 changes: 6 additions & 0 deletions gitops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,9 @@ spec:
path: root:${ORG_ID}:compute
```
## Workspace Controller
Pipeline Service deploys a controller named 'settings controller' into every kcp user workspace that is created for consuming Pipeline Service. This controller enforces a few restrictions in the user workspace such as Quotas and Network Policies.
- Quotas limit the amount of compute resources that can be consumed.
- NetworkPolicies restrict the access granted to the pods running the pipeline tasks to support hermetic builds.

More information on the controller can be found [here](https://github.com/openshift-pipelines/pipeline-service-workspace-controller).
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/openshift-pipelines/pipeline-service-workspace-controller/config/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base
images:
- name: quay.io/redhat-pipeline-service/settings-operator
newName: quay.io/redhat-pipeline-service/settings-operator
newTag: latest
namespace: settings-pipeline-service-controller
41 changes: 41 additions & 0 deletions images/kcp-registrar/bin/register.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,45 @@ configure_synctarget_ws() {
fi
}

check_cr_sync() {
# Wait until CRDs are synced to KCP
echo -n "- Sync CRDs to KCP: "
local cr_regexp
cr_regexp="$(
IFS=\|
echo "${CRS_TO_SYNC[*]}"
)"
cr_regexp=$(echo "$cr_regexp" | tr "," \|)
readarray -td, crs_to_sync_arr <<<"$CRS_TO_SYNC"; declare -p crs_to_sync_arr >/dev/null;

local wait_period=0
while [[ "$(KUBECONFIG=${kcp_kcfg} kubectl api-resources -o name 2>&1 | grep -Ewc "$cr_regexp")" -ne ${#crs_to_sync_arr[@]} ]]; do
wait_period=$((wait_period + 10))
#when wait_period is reached, print out the CR resources that is not synced to KCP
if [ "$wait_period" -gt 300 ]; then
echo "Failed to sync following resources to KCP: "
cr_synced=$(KUBECONFIG="$KUBECONFIG_KCP" kubectl api-resources -o name)
for cr in "${CRS_TO_SYNC[@]}"; do
if [ "$(echo "$cr_synced" | grep -wc "$cr")" -eq 0 ]; then
echo " * $cr"
fi
done
exit 1
fi
echo -n "."
sleep 10
done
echo "OK"
}

install_workspace_controller() {
ws_controller_manifests="$WORKSPACE_DIR/environment/kcp/workspace-controller/overlays"
if [[ -d "$ws_controller_manifests" ]]; then
printf "Deploying Workspace Controller into the workspace\n"
KUBECONFIG=${kcp_kcfg} kubectl apply -k "$ws_controller_manifests" | indent 2
fi
}

main() {
parse_args "$@"
prechecks
Expand All @@ -283,6 +322,8 @@ main() {
register_cluster 2>&1 | indent 2
done
configure_synctarget_ws
check_cr_sync
install_workspace_controller
}

if [ "${BASH_SOURCE[0]}" == "$0" ]; then
Expand Down

0 comments on commit 037effa

Please sign in to comment.