logo
Alauda DevOps Pipelines Docs
logo
Alauda DevOps Pipelines Docs
Navigation

Overview

Introduction
Architecture
Feature Overview
Quick Start
Lifecycle Policy
Release Notes

Concepts

TektonConfig
TektonPipeline
Install

Upgrade

Upgrade Path
Upgrade Alauda DevOps Pipelines Operator

Configure

Adjusting Optional Configuration Items of Subcomponents
Configuring Resource Quotas for Pipeline Components
Pod Template Configuration Guide
Regular Cleanup of TaskRun and PipelineRun Resources

How To

Deploying tekton-pipelines in a global cluster through TektonConfig

Pipelines

Introduction
Architecture

Concepts

Tasks
TaskRuns
Pipelines
PipelineRuns
StepActions
Resolvers
Workspaces
Pod Templates
Quick Start

How To

Adjust Dockerfile for Building Task-Compatible Custom Images
Specifying remote pipelines using hub resolvers
Specifying remote tasks using hub resolvers
Use java-image-build-scan-deploy Pipeline

Trouble Shooting

Failed to create pod due to config error when using custom images in Tekton
Permission Issues When Using Custom Images in run-script Task
Unable to Use Multiple PVC Workspaces in Tekton
permissions

Triggers

Introduction
Architecture

Core Concepts

Core Concepts
EventListener
Trigger
Interceptor
TriggerBinding
TriggerTemplate
Quick Start

How To

Setup EventListener
Use GitLab Event Triggers
Create TriggerTemplate

Troubleshooting

The Pipeline is not automatically triggered
Permission Description

Hub

Introduction
Architecture

Core Concepts

Concepts
Understanding Tekton Hub
Permission Description

Results

Introduction
Architecture

Concepts

Core Concepts
Tekton Results
Quick Start
permissions

Configure

Database Configuration

Supply Chain Security

Introduction
Architecture

Concepts

Core Concepts
Understanding Tekton Chains

Quick Start

Getting Started
Signed Provenance

How To

Image Signature Verification
Build System Provenance Verification
Source Code Repository Verification
Vulnerability Scanning and Verification
Base Image and SBOM Verification
License Compliance Verification
Keyless Signing Verification

Configure

Chains Configuration
Chains Configuration
Authentication for Chains
Signing Key Configuration

API Reference

Introduction

Kubernetes APIs

Pipelines

Pipeline [tekton.dev/v1]
Task [tekton.dev/v1]
PipelineRun [tekton.dev/v1]
TaskRun [tekton.dev/v1]
ClusterTask [tekton.dev/v1]
Run [tekton.dev/v1]
CustomRun [tekton.dev/v1]
StepAction [tekton.dev/v1]
VerificationPolicy [tekton.dev/v1alpha1]
ResolutionRequest [resolution.tekton.dev/v1beta1]

Triggers

Trigger [triggers.tekton.dev/v1beta1]
TriggerTemplate [triggers.tekton.dev/v1beta1]
EventListener [triggers.tekton.dev/v1beta1]
TriggerBinding [triggers.tekton.dev/v1beta1]
Interceptor [triggers.tekton.dev/v1alpha1]
ClusterTriggerBinding [triggers.tekton.dev/v1beta1]
ClusterInterceptor [triggers.tekton.dev/v1alpha1]

Operator

TektonConfig [operator.tekton.dev/v1alpha1]
TektonInstallerSet [operator.tekton.dev/v1alpha1]
TektonPipeline [operator.tekton.dev/v1alpha1]
TektonTrigger [operator.tekton.dev/v1alpha1]
TektonChain [operator.tekton.dev/v1alpha1]
TektonHub [operator.tekton.dev/v1alpha1]
TektonResult [operator.tekton.dev/v1alpha1]
TektonInstallerSet [operator.tekton.dev/v1alpha1]
OpenShift Pipelines as Code [operator.tekton.dev/v1alpha1]

Advanced APIs

Results

Introduction to API Usage
Results List
Results Details
Result records List
Result logs List
📝 Edit this page on GitHub
Previous PageFailed to create pod due to config error when using custom images in Tekton
Next PageUnable to Use Multiple PVC Workspaces in Tekton

#Permission Issues When Using Custom Images in run-script Task

#TOC

#Problem Description

When using custom images in the Tekton run-script Task, you may encounter issues with insufficient file permissions. This situation usually occurs when the Task is configured to run with a non-root user, while the applications in the custom image require root permissions to function properly, or when there is no non-root user with UID 65532 in the image.

#Error Manifestation

TaskRun execution fails, and the Pod logs display insufficient permissions:

** Permission denied

#Root Cause Analysis

This issue is typically caused by the following reasons:

  1. The run-script Task is configured with runAsUser: 65532, forcing the Pod to run as a non-root user.
  2. The applications in the custom image require root permissions to execute certain operations, or there is no non-root user with UID 65532 in the image.
  3. The application attempts to access or modify directories or files without permission.

Example Task Configuration:

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: run-script
spec:
  steps:
    - name: run-script
      securityContext:
        runAsNonRoot: true
        runAsUser: 65532

#Problem Troubleshooting

If this issue occurs only when using the custom image, it is recommended to troubleshoot as follows:

  1. Verify whether there are insufficient permissions with the image when run as the root user:

    $ docker run -it --rm --user root ${registry} ${cmd}
  2. Check if the application allows user 65532 to access specific directories or files:

    $ docker run -it --rm --user 65532:65532 ${registry} ${cmd} ls -la /path/to/directory
  3. Check the securityContext configuration of the Task:

    $ kubectl get task run-script -o yaml | grep -E 'runAsUser|runAsNonRoot'

#Solution

#Option 1: Adjust the Custom Image Build Configuration

#Prerequisites

  • Access and permissions to rebuild the image.

#Steps

  1. Refer to the document on Adjusting Dockerfile for Task-Compatible Custom Images to modify the Dockerfile configuration.
  2. Ensure that the applications in the image can run normally as user 65532.
  3. Set appropriate permissions for directories and files.

#Option 2: Adjust the Application Configuration

#Prerequisites

  • The application supports configuration adjustments via environment variables or parameters.

#Steps

  1. Set the HOME environment variable to point to a directory where permissions are adequate:

    # Set HOME environment variable to a temporary directory
    $ export HOME=$(mktemp -d)
    # Set git's safe.directory configuration
    $ git config --global --add safe.directory /workspace/source
  2. Use application parameters to specify the location of the configuration file:

    # Use skopeo's --authfile parameter to specify the location of the authentication file
    $ skopeo --authfile /workspace/auth.json copy docker://${registry}/${image}:${tag} docker://${registry}/${image}:${tag}

#Option 3: Modify the Task Configuration

#Prerequisites

  • Permissions to modify the Task.
  • Evaluate security risks.

#Steps

  1. Remove the runAsNonRoot and runAsUser configurations:

    apiVersion: tekton.dev/v1
    kind: Task
    metadata:
      name: run-script
    spec:
      steps:
        - name: run-script
          securityContext:
            # runAsNonRoot: true
            # runAsUser: 65532
  2. Alternatively, modify runAsUser to a user with sufficient permissions:

    apiVersion: tekton.dev/v1
    kind: Task
    metadata:
      name: run-script
    spec:
      steps:
        - name: run-script
          securityContext:
            # runAsNonRoot: true
            runAsUser: 0

#Preventive Measures

  1. Image Build

    • Prefer building images with non-root users.
    • Use UID 65532 consistently as a non-root user.
    • Ensure that applications can run normally as non-root users.
    • Set appropriate permissions for directories and files.
  2. Permission Management

    • Follow the principle of least privilege.
    • Plan directory permissions in advance.
    • Regularly review permission configurations.
    • Avoid running containers as root users.
  3. Application Configuration

    • Use environment variables or parameters to adjust configurations.
    • Avoid hard-coding file paths.
    • Support customization of configuration file locations.

#Related Content

  • Adjusting Dockerfile for Task-Compatible Custom Images
  • Official Dockerfile Documentation
  • Dockerfile Best Practices