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

Configuration of Tekton Dashboard service url content path #3607

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
streamLogs = flag.Bool("stream-logs", true, "Enable log streaming instead of polling")
externalLogs = flag.String("external-logs", "", "External logs provider URL")
xFrameOptions = flag.String("x-frame-options", "DENY", "Value for the X-Frame-Options response header, set '' to omit it")
contentPathPrefix = flag.String("content-path-prefix", "", "Value for content root path prefix when calling Tekton API in case Tekton is not exposed on root path")
)

func main() {
Expand Down Expand Up @@ -74,6 +75,7 @@ func main() {
StreamLogs: *streamLogs,
ExternalLogsURL: *externalLogs,
XFrameOptions: *xFrameOptions,
ContentPathPrefix: *contentPathPrefix,
}

resource := endpoints.Resource{
Expand Down
12 changes: 12 additions & 0 deletions docs/walkthrough/walkthrough-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,18 @@ kubectl patch deployment tekton-dashboard -n tekton-pipelines --type='json' \
--patch='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--external-logs=http://logs-server.tools.svc.cluster.local:3000/logs"}]'
```

---
(Optional)
Potentially, if your Tekton Dashboard is exposed on nonroot content path e.g. http://logs.127.0.0.1.nip.io/ci/tekton patch Dashboard deployment to a add the `--content-path-prefix=/ci/tekton` option:

```bash
kubectl patch deployment tekton-dashboard -n tekton-pipelines --type='json' \
--patch='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--content-path-prefix=/ci/tekton"}]'
```
Of course instead of the `/ci/tekton` provide your actual value

---

The logs are now displayed again, fetched from the logs server configured in the previous steps.

![Logs are available again](./walkthrough-logs-logs.png)
Expand Down
4 changes: 3 additions & 1 deletion pkg/endpoints/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package endpoints
import (
"encoding/json"
"net/http"
"strings"

"github.com/tektoncd/dashboard/pkg/logging"
)
Expand All @@ -34,6 +35,7 @@ type Properties struct {
TenantNamespaces []string `json:"tenantNamespaces,omitempty"`
TriggersNamespace string `json:"triggersNamespace,omitempty"`
TriggersVersion string `json:"triggersVersion,omitempty"`
ContentRootPath string `json:"contentRootPath,omitempty"`
}

// GetProperties is used to get the installed namespace for the Dashboard,
Expand All @@ -58,7 +60,7 @@ func (r Resource) GetProperties(response http.ResponseWriter, _ *http.Request) {
}

if r.Options.ExternalLogsURL != "" {
properties.ExternalLogsURL = "/v1/logs-proxy"
properties.ExternalLogsURL = strings.TrimSuffix(r.Options.ContentPathPrefix, "/") + "/v1/logs-proxy"
}

isTriggersInstalled := IsTriggersInstalled(r, triggersNamespace)
Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoints/externallogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (r Resource) LogsProxy(response http.ResponseWriter, request *http.Request)
return
}

uri := strings.TrimPrefix(request.URL.Path, "/v1/logs-proxy") + "?" + parsedURL.RawQuery
uri := strings.TrimPrefix(strings.TrimPrefix(request.URL.Path, r.Options.ContentPathPrefix), "/v1/logs-proxy") + "?" + parsedURL.RawQuery

if statusCode, err := utils.Proxy(request, response, r.Options.ExternalLogsURL+uri, http.DefaultClient); err != nil {
utils.RespondError(response, err, statusCode)
Expand Down
1 change: 1 addition & 0 deletions pkg/endpoints/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Options struct {
StreamLogs bool
ExternalLogsURL string
XFrameOptions string
ContentPathPrefix string
}

// GetPipelinesNamespace returns the PipelinesNamespace property if set
Expand Down