Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readonly property to Tekton Dashboard component #402

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/TekonDashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
name: dashboard
spec:
targetNamespace: tekton-pipelines
readonly: false
```
You can install this component using [TektonConfig](./TektonConfig.md) by choosing appropriate `profile`.

Expand Down
35 changes: 26 additions & 9 deletions docs/TektonConfig.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tekton Config

TektonConfig custom resource is the top most component of the operator which allows user to install and customize all other
TektonConfig custom resource is the top most component of the operator which allows user to install and customize all other
components at a single place.

Operator provides support for installing and managing following operator components through `TektonConfig`:
Expand All @@ -11,7 +11,7 @@ Other than the above components depending on the platform operator also provides
- On Kubernetes
- [TektonDashboard](./TekonDashboard.md)
- On OpenShift
- [TektonAddon](./TektonAddon.md)
- [TektonAddon](./TektonAddon.md)

The TektonConfig CR provides the following features

Expand All @@ -35,7 +35,8 @@ The TektonConfig CR provides the following features
require-git-ssh-secret-known-hosts: false
running-in-environment-with-injected-sidecars: true
pruner: {}
addon: {}
addon: {}
dashboard: {}
```
Look for the particular section to understand a particular field in the spec.

Expand All @@ -45,21 +46,21 @@ This allows user to choose a namespace to install all the pipelines, triggers an
By default, namespace would be `tekton-pipelines` for Kubernetes and `openshift-pipelines` for OpenShift.

### Profile
This allows user to choose which all components to install on the cluster.
This allows user to choose which all components to install on the cluster.
There are 3 profiles available:
- `all`: This profile will install all components
- `all`: This profile will install all components
- `basic`: This profile will install TektonPipeline and TektonTrigger component
- `lite`: This profile will install only TektonPipeline component

On Kubernetes, `all` profile will install `TektonDashboard` and on OpenShift `TektonAddon` will be installed.
On Kubernetes, `all` profile will install `TektonDashboard` and on OpenShift `TektonAddon` will be installed.


### Config
Config provides fields to configure deployments created by the Operator.
This provides following fields:
- [`nodeSelector`][node-selector]
- [`toleration`][toleration]

User can pass the required fields and this would be passed to all Operator components which will get added in all
deployments created by Operator.

Expand All @@ -72,7 +73,7 @@ config:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
effect: "NoSchedule"
```

This is an `Optional` section.
Expand Down Expand Up @@ -122,7 +123,7 @@ This is an `Optional` section.

### Addon

TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few ClusterTasks, PipelineTemplates.
TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few ClusterTasks, PipelineTemplates.

This section allows to customize installation of those resources through params. You can read more about the supported params [here](./TektonAddon.md).

Expand All @@ -139,6 +140,22 @@ addon:
**NOTE**: TektonAddon is currently available for OpenShift Platform only. Enabling this for Kubernetes platform is in roadmap
of Operator.

### Dashboard

Dashboard provides configuration options for the Tekton Dashboard if the specified profile value includes the Dashboard component. (E.g. `all` on Kubernetes)

Example:

```yaml
dashboard:
readonly: true
```

- `readonly`: If set to true, install the Dashboard in read-only mode

This is an `Optional` section.


[node-selector]:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
[toleration]:https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
[schedule]:https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax
14 changes: 13 additions & 1 deletion hack/fetch-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ release_yaml() {
dir="trigger"
fi

#nightly -> 0.0.0-nightly
if [[ $comp == "dashboard" ]]; then
if [[ ${releaseFileName} == "tekton-dashboard-release" ]]; then
dir="dashboard/tekton-dashboard-fullaccess"
fi

if [[ ${releaseFileName} == "tekton-dashboard-release-readonly" ]]; then
dir="dashboard/tekton-dashboard-readonly"
fi
fi


#nightly -> 0.0.0-nightly`
#latest -> find version till then -> 0.0.0-latest
#version -> directory with version

Expand Down Expand Up @@ -97,6 +108,7 @@ main() {
if [[ ${TARGET} != "openshift" ]]; then
d_version=${4}
release_yaml dashboard tekton-dashboard-release 00-dashboard ${d_version}
release_yaml dashboard tekton-dashboard-release-readonly 00-dashboard ${d_version}

r_version=${5}
release_yaml results release 00-results ${r_version}
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type TektonConfigSpec struct {
// Trigger holds the customizable option for triggers component
// +optional
Trigger Trigger `json:"trigger,omitempty"`
// Dashboard holds the customizable options for dashboards component
// +optional
Dashboard Dashboard `json:"dashboard,omitempty"`
}

// TektonConfigStatus defines the observed state of TektonConfig
Expand Down Expand Up @@ -130,6 +133,11 @@ type Trigger struct {
TriggersProperties `json:",inline"`
}

// Dashboard degines the fields to customize the Dashboard component
type Dashboard struct {
DashboardProperties `json:",inline"`
}

type Config struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Expand Down
9 changes: 8 additions & 1 deletion pkg/apis/operator/v1alpha1/tektondashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func (tp *TektonDashboard) GetStatus() TektonComponentStatus {

// TektonDashboardSpec defines the desired state of TektonDashboard
type TektonDashboardSpec struct {
CommonSpec `json:",inline"`
CommonSpec `json:",inline"`
DashboardProperties `json:",inline"`
// Config holds the configuration for resources created by TektonDashboard
// +optional
Config Config `json:"config,omitempty"`
Expand All @@ -77,3 +78,9 @@ type TektonDashboardList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []TektonDashboard `json:"items"`
}

// Dashboard degines the fields to customize the Dashboard component
type DashboardProperties struct {
// Readonly when set to true configures the Tekton dashboard in read-only mode
Readonly bool `json:"readonly"`
}
35 changes: 35 additions & 0 deletions pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pkg/reconciler/common/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ func Fetch(path string) (mf.Manifest, error) {

func ComponentDir(instance v1alpha1.TektonComponent) string {
koDataDir := os.Getenv(KoEnvKey)
switch instance.(type) {
switch ins := instance.(type) {
case *v1alpha1.TektonPipeline:
return filepath.Join(koDataDir, "tekton-pipeline")
case *v1alpha1.TektonTrigger:
return filepath.Join(koDataDir, "tekton-trigger")
case *v1alpha1.TektonDashboard:
return filepath.Join(koDataDir, "tekton-dashboard")
if ins.Spec.Readonly {
return filepath.Join(koDataDir, "tekton-dashboard/tekton-dashboard-readonly")
}
return filepath.Join(koDataDir, "tekton-dashboard/tekton-dashboard-fullaccess")
case *v1alpha1.TektonAddon:
return filepath.Join(koDataDir, "tekton-addon")
case *v1alpha1.TektonConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func ensureTektonDashboardExists(clients op.TektonDashboardInterface, config *v1
updated = true
}

if !reflect.DeepEqual(tdCR.Spec.DashboardProperties, config.Spec.Dashboard.DashboardProperties) {
tdCR.Spec.DashboardProperties = config.Spec.Dashboard.DashboardProperties
updated = true
}

if !reflect.DeepEqual(tdCR.Spec.Config, config.Spec.Config) {
tdCR.Spec.Config = config.Spec.Config
updated = true
Expand Down Expand Up @@ -84,7 +89,8 @@ func ensureTektonDashboardExists(clients op.TektonDashboardInterface, config *v1
CommonSpec: v1alpha1.CommonSpec{
TargetNamespace: config.Spec.TargetNamespace,
},
Config: config.Spec.Config,
Config: config.Spec.Config,
DashboardProperties: config.Spec.Dashboard.DashboardProperties,
},
}
return clients.Create(context.TODO(), tdCR, metav1.CreateOptions{})
Expand Down
3 changes: 2 additions & 1 deletion tekton/task-fetch-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ spec:

d_version=${4}
release_yaml dashboard tekton-dashboard-release 00-dashboard ${d_version}
release_yaml dashboard tekton-dashboard-release-readonly 00-dashboard-readonly ${d_version}

r_version=${5}
release_yaml results release 00-results ${r_version}
Expand All @@ -138,4 +139,4 @@ spec:
runAsUser: 0
workspaces:
- mountPath: /go/src/github.com/tektoncd/operator
name: source
name: source
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ type LRUCache interface {
// Clears all cache entries.
Purge()

// Resizes cache, returning number evicted
Resize(int) int
// Resizes cache, returning number evicted
Resize(int) int
}