Docker-Desktop
MAC
Kubernetes
ServiceAccounts
Troubleshooting

Docker-Desktop for MAC Kubernetes not creating secrets or token for serviceaccounts

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Docker Desktop for Mac is an essential tool for developers who want to run Docker containers and Kubernetes clusters locally. However, users sometimes encounter issues, such as Kubernetes not creating secrets or tokens for service accounts. In this article, we'll delve into the reasons behind this issue, provide technical explanations, and explore potential solutions.

Understanding the Problem

Service Accounts and Tokens

In Kubernetes, a ServiceAccount is a special type of account used by processes within pods to interact with the Kubernetes API. By default, service accounts are automatically given an API token stored as a secret, which gets mounted into the pod. This token allows the pod to authenticate with the API server.

The Issue

The problem arises when Kubernetes running under Docker Desktop for Mac fails to automatically create these secrets or tokens for service accounts. This can lead to authorization issues, as pods may be unable to authenticate with the Kubernetes API server.

Technical Explanation

Default Token Creation

Under normal circumstances, when a service account is created in Kubernetes, an associated secret containing the API token is automatically generated. This secret is created by the kube-controller-manager , which monitors the creation of service accounts and ensures that an API token is provisioned and stored as a secret.

Potential Causes

  1. Misconfiguration of kube-controller-manager:
    If the controller manager is misconfigured, it might not be monitoring service account creation events, leading to the absence of secret generation.
  2. Cluster Role Bindings:
    Insufficient cluster roles or bindings can prevent the controller manager from performing necessary operations, such as creating secrets for service accounts.
  3. Resource Constraints:
    Running Kubernetes in environments with limited resources may result in failure or delays in secret creation due to the controller manager being starved of CPU or memory.
  4. Docker Desktop Settings:
    Improper settings in Docker Desktop's Kubernetes configuration could lead to these issues.

Investigating the Issue

Initial Checks

Begin by verifying whether the kube-controller-manager is functioning correctly.

  • Docker Desktop CPU/Memory Limits:
  • Increase the CPU cores and memory allocation within Docker Desktop settings. An allocation of at least 4GB RAM and 2 CPU cores is recommended for smooth operation.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design