Repository: rancher/fleet
Pull request #1624 (2023-06-29 15:22:09)

Restructure package layout to add internal package
Open questions, that were ignored for this round of refactorings:

* the "test" command still imports `options` and `matcher` from controller and doesn't work very well.
* there is an internal folder below the agents `deployer`, because that code is copied.
* the binaries packages are in folders that are prefixed with `fleet`, like `internal/fleetcli`, each has a `cmds` package.

I wanted to avoid nesting too deep, but packages like `render` or `update` had such generic names, that I wanted them out of the way, in a subfolder of their only consumer.


Example instructions that were used:
```
function R() {
  s="$1"
  r="$2"

  rg -l "fleet/$s" **/*.go | xargs gsed -i "s|fleet/$s|fleet/$r|g"
}

git mv modules/agent/cmds internal/agent/cmds
R modules/agent/cmds internal/agent/cmds
goimports .
```


manno: 
# Before:

<details>

```
cmd
├── docs
├── fleetagent
└── fleetcontroller
internal
└── mocks
modules
├── agent
│   ├── cmds
│   └── pkg
│       ├── agent
│       ├── controllers
│       │   ├── bundledeployment
│       │   └── cluster
│       ├── deployer
│       │   ├── internal
│       │   │   ├── diff
│       │   │   ├── diffnormalize
│       │   │   ├── glob
│       │   │   ├── json
│       │   │   ├── kubernetes_vendor
│       │   │   │   └── pkg
│       │   │   │       ├── api
│       │   │   │       │   └── v1
│       │   │   │       │       └── endpoints
│       │   │   │       └── util
│       │   │   │           └── hash
│       │   │   ├── normalizers
│       │   │   ├── resource
│       │   │   └── scheme
│       │   └── normalizers
│       ├── globals
│       ├── register
│       └── trigger
├── cli
│   ├── apply
│   ├── cmds
│   ├── match
│   └── pkg
│       ├── client
│       ├── progress
│       └── writer
└── controller
    └── cmds
pkg
├── agent
├── apis
│   └── fleet.cattle.io
│       └── v1alpha1
├── bundlereader
├── codegen
│   └── cleanup
├── config
├── connection
├── content
├── controllers
│   ├── bootstrap
│   ├── bundle
│   ├── cleanup
│   ├── cluster
│   ├── clustergroup
│   ├── clusterregistration
│   ├── clusterregistrationtoken
│   ├── config
│   ├── content
│   ├── display
│   ├── git
│   ├── image
│   └── manageagent
├── crd
├── display
├── durations
├── fleetcontroller
├── fleetyaml
├── generated
│   └── controllers
│       └── fleet.cattle.io
│           └── v1alpha1
├── helmdeployer
├── kustomize
├── manifest
├── name
├── namespace
├── options
├── patch
├── rawyaml
├── registration
├── render
├── secret
├── summary
├── target
│   └── matcher
├── update
└── version
```
</details>


manno: 
# Alternative, with internal/pkg

<details>

```
cmd
├── codegen
│   └── cleanup
├── docs
├── fleetagent
└── fleetcontroller
internal
├── agent
│   ├── agent
│   ├── cmds
│   ├── controllers
│   │   ├── bundledeployment
│   │   └── cluster
│   ├── deployer
│   │   ├── internal
│   │   │   ├── diff
│   │   │   ├── diffnormalize
│   │   │   ├── glob
│   │   │   ├── json
│   │   │   ├── kubernetes_vendor
│   │   │   │   └── pkg
│   │   │   │       ├── api
│   │   │   │       │   └── v1
│   │   │   │       │       └── endpoints
│   │   │   │       └── util
│   │   │   │           └── hash
│   │   │   ├── normalizers
│   │   │   ├── resource
│   │   │   └── scheme
│   │   └── normalizers
│   ├── globals
│   ├── register
│   └── trigger
├── cli
│   ├── apply
│   ├── cmds
│   ├── match
│   └── writer
├── cmd
│   ├── agent
│   │   └── cmds
│   ├── cli
│   │   └── cmds
│   └── controller
│       └── cmds
├── controller
│   ├── agent
│   ├── cmds
│   ├── connection
│   ├── controllers
│   │   ├── bootstrap
│   │   ├── bundle
│   │   ├── cleanup
│   │   ├── cluster
│   │   ├── clustergroup
│   │   ├── clusterregistration
│   │   ├── clusterregistrationtoken
│   │   ├── config
│   │   ├── content
│   │   ├── display
│   │   ├── git
│   │   ├── image
│   │   │   └── update
│   │   └── manageagent
│   ├── display
│   ├── fleetcontroller
│   ├── mocks
│   ├── namespace
│   ├── options
│   ├── secret
│   ├── summary
│   └── target
│       └── matcher
└── pkg
    ├── bundlereader
    │   └── progress
    ├── client
    ├── config
    ├── content
    ├── fleetyaml
    ├── helmdeployer
    │   ├── kustomize
    │   ├── rawyaml
    │   └── render
    │       └── patch
    ├── manifest
    ├── name
    └── registration
pkg
├── apis
│   └── fleet.cattle.io
│       └── v1alpha1
├── crd
├── durations
├── generated
│   └── controllers
│       └── fleet.cattle.io
│           └── v1alpha1
└── version
```
</details>



manno: # Alternative, with prefixed cmd pkgs:

<details>

```
cmd
├── codegen
│   └── cleanup
├── docs
├── fleetagent
└── fleetcontroller
internal
├── bundlereader
│   └── progress
├── client
├── config
├── content
├── fleetagent
│   ├── agent
│   ├── cmds
│   ├── controllers
│   │   ├── bundledeployment
│   │   └── cluster
│   ├── deployer
│   │   ├── internal
│   │   │   ├── diff
│   │   │   ├── diffnormalize
│   │   │   ├── glob
│   │   │   ├── json
│   │   │   ├── kubernetes_vendor
│   │   │   │   └── pkg
│   │   │   │       ├── api
│   │   │   │       │   └── v1
│   │   │   │       │       └── endpoints
│   │   │   │       └── util
│   │   │   │           └── hash
│   │   │   ├── normalizers
│   │   │   ├── resource
│   │   │   └── scheme
│   │   └── normalizers
│   ├── globals
│   ├── register
│   └── trigger
├── fleetcli
│   ├── apply
│   ├── cmds
│   ├── match
│   └── writer
├── fleetcontroller
│   ├── agent
│   ├── cmds
│   ├── connection
│   ├── controllers
│   │   ├── bootstrap
│   │   ├── bundle
│   │   ├── cleanup
│   │   ├── cluster
│   │   ├── clustergroup
│   │   ├── clusterregistration
│   │   ├── clusterregistrationtoken
│   │   ├── config
│   │   ├── content
│   │   ├── display
│   │   ├── git
│   │   ├── image
│   │   │   └── update
│   │   └── manageagent
│   ├── display
│   ├── fleetcontroller
│   ├── mocks
│   ├── namespace
│   ├── options
│   ├── secret
│   ├── summary
│   └── target
│       └── matcher
├── fleetyaml
├── helmdeployer
│   ├── kustomize
│   ├── rawyaml
│   └── render
│       └── patch
├── manifest
├── name
├── pkg
└── registration
pkg
├── apis
│   └── fleet.cattle.io
│       └── v1alpha1
├── crd
├── durations
├── generated
│   └── controllers
│       └── fleet.cattle.io
│           └── v1alpha1
└── version
```
</details>


manno: 
# Alternative cmd in internal/cmd

<details>

```
cmd
├── codegen
│   └── cleanup
├── docs
├── fleetagent
└── fleetcontroller
internal
├── bundlereader
│   └── progress
├── client
├── cmd
│   ├── agent
│   │   ├── agent
│   │   ├── cmds
│   │   ├── controllers
│   │   │   ├── bundledeployment
│   │   │   └── cluster
│   │   ├── deployer
│   │   │   ├── internal
│   │   │   │   ├── diff
│   │   │   │   ├── diffnormalize
│   │   │   │   ├── glob
│   │   │   │   ├── json
│   │   │   │   ├── kubernetes_vendor
│   │   │   │   │   └── pkg
│   │   │   │   │       ├── api
│   │   │   │   │       │   └── v1
│   │   │   │   │       │       └── endpoints
│   │   │   │   │       └── util
│   │   │   │   │           └── hash
│   │   │   │   ├── normalizers
│   │   │   │   ├── resource
│   │   │   │   └── scheme
│   │   │   └── normalizers
│   │   ├── globals
│   │   ├── register
│   │   └── trigger
│   ├── cli
│   │   ├── apply
│   │   ├── cmds
│   │   ├── match
│   │   └── writer
│   └── controller
│       ├── agent
│       ├── cmds
│       ├── connection
│       ├── controllers
│       │   ├── bootstrap
│       │   ├── bundle
│       │   ├── cleanup
│       │   ├── cluster
│       │   ├── clustergroup
│       │   ├── clusterregistration
│       │   ├── clusterregistrationtoken
│       │   ├── config
│       │   ├── content
│       │   ├── display
│       │   ├── git
│       │   ├── image
│       │   │   └── update
│       │   └── manageagent
│       ├── display
│       ├── fleetcontroller
│       ├── mocks
│       ├── namespace
│       ├── options
│       ├── secret
│       ├── summary
│       └── target
│           └── matcher
├── config
├── content
├── fleetyaml
├── helmdeployer
│   ├── kustomize
│   ├── rawyaml
│   └── render
│       └── patch
├── manifest
├── name
└── registration
pkg
├── apis
│   └── fleet.cattle.io
│       └── v1alpha1
├── crd
├── durations
├── generated
│   └── controllers
│       └── fleet.cattle.io
│           └── v1alpha1
└── version
```
</details>

Patch:
diff --git a/.github/scripts/check-for-auto-generated-changes.sh b/.github/scripts/check-for-auto-generated-changes.sh
index 4f25fbf7..b6fd8768 100755
--- a/.github/scripts/check-for-auto-generated-changes.sh
+++ b/.github/scripts/check-for-auto-generated-changes.sh
@@ -1,10 +1,10 @@
 #!/bin/sh
 set -ue
 
-go run pkg/codegen/cleanup/main.go > /dev/null
-go run pkg/codegen/main.go
+go run cmd/codegen/cleanup/main.go > /dev/null
+go run cmd/codegen/main.go
 
-go run ./pkg/codegen crds ./charts/fleet-crd/templates/crds.yaml > /dev/null
+go run ./cmd/codegen crds ./charts/fleet-crd/templates/crds.yaml > /dev/null
 
 if [ -n "$(git status --porcelain)" ]; then
     echo "Generated files have either been changed manually or were not updated.\n"
diff --git a/.github/workflows/aks.yml b/.github/workflows/aks.yml
index 6cfab42e..e314c2da 100644
--- a/.github/workflows/aks.yml
+++ b/.github/workflows/aks.yml
@@ -79,7 +79,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Set up QEMU
diff --git a/.github/workflows/eks.yml b/.github/workflows/eks.yml
index ac4b6a51..493a5151 100644
--- a/.github/workflows/eks.yml
+++ b/.github/workflows/eks.yml
@@ -92,7 +92,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Get UUID
diff --git a/.github/workflows/fleet-upgrade.yml b/.github/workflows/fleet-upgrade.yml
index 8b2eb110..cdf53a68 100644
--- a/.github/workflows/fleet-upgrade.yml
+++ b/.github/workflows/fleet-upgrade.yml
@@ -77,7 +77,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Build Docker Images
diff --git a/.github/workflows/gke.yml b/.github/workflows/gke.yml
index 5dd7fa72..4e31462e 100644
--- a/.github/workflows/gke.yml
+++ b/.github/workflows/gke.yml
@@ -83,7 +83,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Set up QEMU
diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml
index ba0cb5b3..5214f722 100644
--- a/.github/workflows/nightly-ci.yml
+++ b/.github/workflows/nightly-ci.yml
@@ -53,7 +53,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Build Docker Images
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index c688265b..7a4c6d1b 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -65,11 +65,11 @@ jobs:
         run: |
           export GOARCH=amd64
           go build -gcflags='all=-N -l' -o bin/fleetcontroller-linux-amd64 ./cmd/fleetcontroller
-          go build -gcflags='all=-N -l' -o bin/fleet-linux-amd64
+          go build -gcflags='all=-N -l' -o bin/fleet-linux-amd64 ./cmd/fleetcli
           go build -gcflags='all=-N -l' -o bin/fleetagent-linux-amd64 ./cmd/fleetagent
           export GOARCH=arm64
           go build -gcflags='all=-N -l' -o bin/fleetcontroller-linux-arm64 ./cmd/fleetcontroller
-          go build -gcflags='all=-N -l' -o bin/fleet-linux-arm64
+          go build -gcflags='all=-N -l' -o bin/fleet-linux-arm64 ./cmd/fleetcli
           go build -gcflags='all=-N -l' -o bin/fleetagent-linux-arm64 ./cmd/fleetagent
       -
         id: meta-fleet
diff --git a/.github/workflows/rancher-integration.yml b/.github/workflows/rancher-integration.yml
index 60cd5c76..2d37ccf8 100644
--- a/.github/workflows/rancher-integration.yml
+++ b/.github/workflows/rancher-integration.yml
@@ -74,7 +74,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Set up QEMU
diff --git a/pkg/codegen/cleanup/main.go b/cmd/codegen/cleanup/main.go
similarity index 100%
rename from pkg/codegen/cleanup/main.go
rename to cmd/codegen/cleanup/main.go
diff --git a/pkg/codegen/main.go b/cmd/codegen/main.go
similarity index 100%
rename from pkg/codegen/main.go
rename to cmd/codegen/main.go
diff --git a/cmd/docs/generate-cli-docs.go b/cmd/docs/generate-cli-docs.go
index d5da1d1b..1564c949 100644
--- a/cmd/docs/generate-cli-docs.go
+++ b/cmd/docs/generate-cli-docs.go
@@ -9,9 +9,9 @@ import (
 
 	"github.com/pkg/errors"
 
-	fleetagent "github.com/rancher/fleet/modules/agent/cmds"
-	fleetcli "github.com/rancher/fleet/modules/cli/cmds"
-	fleetcontroller "github.com/rancher/fleet/modules/controller/cmds"
+	fleetagent "github.com/rancher/fleet/internal/cmd/agent"
+	fleetcli "github.com/rancher/fleet/internal/cmd/cli"
+	fleetcontroller "github.com/rancher/fleet/internal/cmd/controller"
 
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra/doc"
diff --git a/cmd/fleetagent/main.go b/cmd/fleetagent/main.go
index 0cafb508..0fb5d6d6 100644
--- a/cmd/fleetagent/main.go
+++ b/cmd/fleetagent/main.go
@@ -1,14 +1,14 @@
-// Package main is the entrypoint for the fleet-agent binary. (fleetagent)
+// Package main is the entrypoint for the fleet-agent binary.
 package main
 
 import (
 	_ "net/http/pprof"
 
-	"github.com/rancher/fleet/modules/agent/cmds"
+	"github.com/rancher/fleet/internal/cmd/agent"
 
 	command "github.com/rancher/wrangler-cli"
 )
 
 func main() {
-	command.Main(cmds.App())
+	command.Main(agent.App())
 }
diff --git a/main.go b/cmd/fleetcli/main.go
similarity index 82%
rename from main.go
rename to cmd/fleetcli/main.go
index 283b2657..bc1a5af9 100644
--- a/main.go
+++ b/cmd/fleetcli/main.go
@@ -1,8 +1,8 @@
-// Package main is the entry point for the fleet apply binary. (fleetapply)
+// Package main is the entry point for the fleet apply binary.
 package main
 
 import (
-	"github.com/rancher/fleet/modules/cli/cmds"
+	cmds "github.com/rancher/fleet/internal/cmd/cli"
 
 	command "github.com/rancher/wrangler-cli"
 
diff --git a/cmd/fleetcontroller/main.go b/cmd/fleetcontroller/main.go
index e5e7dd7b..96e5d895 100644
--- a/cmd/fleetcontroller/main.go
+++ b/cmd/fleetcontroller/main.go
@@ -1,10 +1,10 @@
-// Package main provides the entrypoint for the fleet-controller binary (fleetcontroller)
+// Package main provides the entrypoint for the fleet-controller binary.
 package main
 
 import (
 	_ "net/http/pprof"
 
-	controller "github.com/rancher/fleet/modules/controller/cmds"
+	"github.com/rancher/fleet/internal/cmd/controller"
 
 	command "github.com/rancher/wrangler-cli"
 	_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
diff --git a/dev/build-fleet b/dev/build-fleet
index 3a6715e5..acb43187 100755
--- a/dev/build-fleet
+++ b/dev/build-fleet
@@ -22,6 +22,6 @@ go build -gcflags='all=-N -l' -o bin/fleetcontroller-linux-"$GOARCH" ./cmd/fleet
 docker build -f package/Dockerfile -t rancher/fleet:dev --build-arg="ARCH=$GOARCH"  .
 
 # fleet agent
-go build -gcflags='all=-N -l' -o "bin/fleet-linux-$GOARCH"
+go build -gcflags='all=-N -l' -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
 go build -gcflags='all=-N -l' -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
 docker build -f package/Dockerfile.agent -t rancher/fleet-agent:dev --build-arg="ARCH=$GOARCH" .
diff --git a/dev/update-agent-k3d b/dev/update-agent-k3d
index cd3f13de..dfd621ec 100755
--- a/dev/update-agent-k3d
+++ b/dev/update-agent-k3d
@@ -12,7 +12,7 @@ export GOARCH="${GOARCH:-amd64}"
 export CGO_ENABLED=0
 
 # fleet agent
-go build -gcflags='all=-N -l' -o "bin/fleet-linux-$GOARCH"
+go build -gcflags='all=-N -l' -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
 go build -gcflags='all=-N -l' -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
 docker build -f package/Dockerfile.agent -t rancher/fleet-agent:dev --build-arg="ARCH=$GOARCH" .
 
diff --git a/generate.go b/generate.go
index ae2ef077..088b1a49 100644
--- a/generate.go
+++ b/generate.go
@@ -1,5 +1,5 @@
-//go:generate go run pkg/codegen/cleanup/main.go
-//go:generate go run pkg/codegen/main.go
-//go:generate go run ./pkg/codegen crds ./charts/fleet-crd/templates/crds.yaml
+//go:generate go run cmd/codegen/cleanup/main.go
+//go:generate go run cmd/codegen/main.go
+//go:generate go run ./cmd/codegen crds ./charts/fleet-crd/templates/crds.yaml
 
 package main
diff --git a/pkg/bundlereader/charturl.go b/internal/bundlereader/charturl.go
similarity index 100%
rename from pkg/bundlereader/charturl.go
rename to internal/bundlereader/charturl.go
diff --git a/pkg/bundlereader/loaddirectory.go b/internal/bundlereader/loaddirectory.go
similarity index 99%
rename from pkg/bundlereader/loaddirectory.go
rename to internal/bundlereader/loaddirectory.go
index 9d47b10a..0c97a954 100644
--- a/pkg/bundlereader/loaddirectory.go
+++ b/internal/bundlereader/loaddirectory.go
@@ -15,8 +15,8 @@ import (
 
 	"github.com/hashicorp/go-getter"
 	"github.com/pkg/errors"
+	"github.com/rancher/fleet/internal/content"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/content"
 	"helm.sh/helm/v3/pkg/cli"
 	"helm.sh/helm/v3/pkg/downloader"
 	helmgetter "helm.sh/helm/v3/pkg/getter"
diff --git a/modules/cli/pkg/progress/progress_tracking.go b/internal/bundlereader/progress/progress_tracking.go
similarity index 100%
rename from modules/cli/pkg/progress/progress_tracking.go
rename to internal/bundlereader/progress/progress_tracking.go
diff --git a/pkg/bundlereader/read.go b/internal/bundlereader/read.go
similarity index 99%
rename from pkg/bundlereader/read.go
rename to internal/bundlereader/read.go
index c09caeb0..4d9dc86e 100644
--- a/pkg/bundlereader/read.go
+++ b/internal/bundlereader/read.go
@@ -13,8 +13,8 @@ import (
 	"path/filepath"
 	"strconv"
 
+	"github.com/rancher/fleet/internal/fleetyaml"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/fleetyaml"
 
 	name1 "github.com/rancher/wrangler/pkg/name"
 
diff --git a/pkg/bundlereader/resources.go b/internal/bundlereader/resources.go
similarity index 98%
rename from pkg/bundlereader/resources.go
rename to internal/bundlereader/resources.go
index 31a747f9..7ccc8c8a 100644
--- a/pkg/bundlereader/resources.go
+++ b/internal/bundlereader/resources.go
@@ -10,7 +10,7 @@ import (
 	"sort"
 	"sync"
 
-	"github.com/rancher/fleet/modules/cli/pkg/progress"
+	"github.com/rancher/fleet/internal/bundlereader/progress"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	"golang.org/x/sync/errgroup"
 	"golang.org/x/sync/semaphore"
diff --git a/pkg/bundlereader/resources_test.go b/internal/bundlereader/resources_test.go
similarity index 100%
rename from pkg/bundlereader/resources_test.go
rename to internal/bundlereader/resources_test.go
diff --git a/pkg/bundlereader/style.go b/internal/bundlereader/style.go
similarity index 97%
rename from pkg/bundlereader/style.go
rename to internal/bundlereader/style.go
index 1c043e36..834ef09b 100644
--- a/pkg/bundlereader/style.go
+++ b/internal/bundlereader/style.go
@@ -4,8 +4,8 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/manifest"
 )
 
 const (
diff --git a/modules/cli/pkg/client/client.go b/internal/client/client.go
similarity index 100%
rename from modules/cli/pkg/client/client.go
rename to internal/client/client.go
diff --git a/modules/agent/pkg/controllers/bundledeployment/controller.go b/internal/cmd/agent/controllers/bundledeployment/controller.go
similarity index 98%
rename from modules/agent/pkg/controllers/bundledeployment/controller.go
rename to internal/cmd/agent/controllers/bundledeployment/controller.go
index 6c986a3a..d1ff3ce6 100644
--- a/modules/agent/pkg/controllers/bundledeployment/controller.go
+++ b/internal/cmd/agent/controllers/bundledeployment/controller.go
@@ -1,4 +1,4 @@
-// Package bundledeployment deploys bundles, monitors them and cleans up. (fleetagent)
+// Package bundledeployment deploys bundles, monitors them and cleans up.
 package bundledeployment
 
 import (
@@ -12,12 +12,12 @@ import (
 
 	"github.com/sirupsen/logrus"
 
-	"github.com/rancher/fleet/modules/agent/pkg/deployer"
-	"github.com/rancher/fleet/modules/agent/pkg/trigger"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer"
+	"github.com/rancher/fleet/internal/cmd/agent/trigger"
+	"github.com/rancher/fleet/internal/helmdeployer"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
 
 	"github.com/rancher/wrangler/pkg/condition"
 	"github.com/rancher/wrangler/pkg/merr"
diff --git a/modules/agent/pkg/controllers/cluster/cluster.go b/internal/cmd/agent/controllers/cluster/cluster.go
similarity index 98%
rename from modules/agent/pkg/controllers/cluster/cluster.go
rename to internal/cmd/agent/controllers/cluster/cluster.go
index 26624aee..feec7e97 100644
--- a/modules/agent/pkg/controllers/cluster/cluster.go
+++ b/internal/cmd/agent/controllers/cluster/cluster.go
@@ -1,4 +1,4 @@
-// Package cluster updates the cluster.fleet.cattle.io status in the upstream cluster with the current node status. (fleetagent)
+// Package cluster updates the cluster.fleet.cattle.io status in the upstream cluster with the current node status.
 package cluster
 
 import (
diff --git a/modules/agent/pkg/controllers/controllers.go b/internal/cmd/agent/controllers/controllers.go
similarity index 94%
rename from modules/agent/pkg/controllers/controllers.go
rename to internal/cmd/agent/controllers/controllers.go
index 8b5303e8..cda1f69a 100644
--- a/modules/agent/pkg/controllers/controllers.go
+++ b/internal/cmd/agent/controllers/controllers.go
@@ -1,4 +1,4 @@
-// Package controllers wires and starts the controllers for the agent. (fleetagent)
+// Package controllers wires and starts the controllers for the agent.
 package controllers
 
 import (
@@ -10,15 +10,15 @@ import (
 	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/client-go/util/workqueue"
 
-	"github.com/rancher/fleet/modules/agent/pkg/controllers/bundledeployment"
-	"github.com/rancher/fleet/modules/agent/pkg/controllers/cluster"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer"
-	"github.com/rancher/fleet/modules/agent/pkg/trigger"
+	"github.com/rancher/fleet/internal/cmd/agent/controllers/bundledeployment"
+	"github.com/rancher/fleet/internal/cmd/agent/controllers/cluster"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer"
+	"github.com/rancher/fleet/internal/cmd/agent/trigger"
+	"github.com/rancher/fleet/internal/helmdeployer"
+	"github.com/rancher/fleet/internal/manifest"
 	"github.com/rancher/fleet/pkg/durations"
 	"github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	"github.com/rancher/fleet/pkg/manifest"
 
 	cache2 "github.com/rancher/lasso/pkg/cache"
 	"github.com/rancher/lasso/pkg/client"
diff --git a/modules/agent/pkg/deployer/internal/diff/diff.go b/internal/cmd/agent/deployer/internal/diff/diff.go
similarity index 98%
rename from modules/agent/pkg/deployer/internal/diff/diff.go
rename to internal/cmd/agent/deployer/internal/diff/diff.go
index 5408850c..8925e2b6 100644
--- a/modules/agent/pkg/deployer/internal/diff/diff.go
+++ b/internal/cmd/agent/deployer/internal/diff/diff.go
@@ -21,9 +21,9 @@ import (
 	"k8s.io/apimachinery/pkg/util/strategicpatch"
 	"k8s.io/client-go/kubernetes/scheme"
 
-	jsonutil "github.com/rancher/fleet/modules/agent/pkg/deployer/internal/json"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints"
-	kubescheme "github.com/rancher/fleet/modules/agent/pkg/deployer/internal/scheme"
+	jsonutil "github.com/rancher/fleet/internal/cmd/agent/deployer/internal/json"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints"
+	kubescheme "github.com/rancher/fleet/internal/cmd/agent/deployer/internal/scheme"
 )
 
 const couldNotMarshalErrMsg = "Could not unmarshal to object of type %s: %v"
diff --git a/modules/agent/pkg/deployer/internal/diff/diff_options.go b/internal/cmd/agent/deployer/internal/diff/diff_options.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/diff/diff_options.go
rename to internal/cmd/agent/deployer/internal/diff/diff_options.go
diff --git a/modules/agent/pkg/deployer/internal/diffnormalize/normalize.go b/internal/cmd/agent/deployer/internal/diffnormalize/normalize.go
similarity index 82%
rename from modules/agent/pkg/deployer/internal/diffnormalize/normalize.go
rename to internal/cmd/agent/deployer/internal/diffnormalize/normalize.go
index 51c3f21a..9fbc5f50 100644
--- a/modules/agent/pkg/deployer/internal/diffnormalize/normalize.go
+++ b/internal/cmd/agent/deployer/internal/diffnormalize/normalize.go
@@ -2,9 +2,9 @@
 package diffnormalize
 
 import (
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/diff"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/normalizers"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/resource"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/diff"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/normalizers"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/resource"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 )
 
diff --git a/modules/agent/pkg/deployer/internal/glob/glob.go b/internal/cmd/agent/deployer/internal/glob/glob.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/glob/glob.go
rename to internal/cmd/agent/deployer/internal/glob/glob.go
diff --git a/modules/agent/pkg/deployer/internal/json/json.go b/internal/cmd/agent/deployer/internal/json/json.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/json/json.go
rename to internal/cmd/agent/deployer/internal/json/json.go
diff --git a/modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go b/internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go
similarity index 96%
rename from modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go
rename to internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go
index 15bca315..c6951429 100644
--- a/modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go
+++ b/internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/api/v1/endpoints/util.go
@@ -22,7 +22,7 @@ import (
 	"hash"
 	"sort"
 
-	hashutil "github.com/rancher/fleet/modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/util/hash"
+	hashutil "github.com/rancher/fleet/internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/util/hash"
 	v1 "k8s.io/api/core/v1"
 )
 
diff --git a/modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/util/hash/hash.go b/internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/util/hash/hash.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/kubernetes_vendor/pkg/util/hash/hash.go
rename to internal/cmd/agent/deployer/internal/kubernetes_vendor/pkg/util/hash/hash.go
diff --git a/modules/agent/pkg/deployer/internal/normalizers/diff_normalizer.go b/internal/cmd/agent/deployer/internal/normalizers/diff_normalizer.go
similarity index 92%
rename from modules/agent/pkg/deployer/internal/normalizers/diff_normalizer.go
rename to internal/cmd/agent/deployer/internal/normalizers/diff_normalizer.go
index b2d22b8a..3d5f2348 100644
--- a/modules/agent/pkg/deployer/internal/normalizers/diff_normalizer.go
+++ b/internal/cmd/agent/deployer/internal/normalizers/diff_normalizer.go
@@ -10,9 +10,9 @@ import (
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime/schema"
 
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/diff"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/glob"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/resource"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/diff"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/glob"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/resource"
 )
 
 type normalizerPatch struct {
diff --git a/modules/agent/pkg/deployer/internal/normalizers/knowntypes_normalizer.go b/internal/cmd/agent/deployer/internal/normalizers/knowntypes_normalizer.go
similarity index 98%
rename from modules/agent/pkg/deployer/internal/normalizers/knowntypes_normalizer.go
rename to internal/cmd/agent/deployer/internal/normalizers/knowntypes_normalizer.go
index 4ea6974e..f2c462d5 100644
--- a/modules/agent/pkg/deployer/internal/normalizers/knowntypes_normalizer.go
+++ b/internal/cmd/agent/deployer/internal/normalizers/knowntypes_normalizer.go
@@ -8,7 +8,7 @@ import (
 
 	log "github.com/sirupsen/logrus"
 
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/resource"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/resource"
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime/schema"
diff --git a/modules/agent/pkg/deployer/internal/resource/ignore.go b/internal/cmd/agent/deployer/internal/resource/ignore.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/resource/ignore.go
rename to internal/cmd/agent/deployer/internal/resource/ignore.go
diff --git a/modules/agent/pkg/deployer/internal/scheme/scheme.go b/internal/cmd/agent/deployer/internal/scheme/scheme.go
similarity index 100%
rename from modules/agent/pkg/deployer/internal/scheme/scheme.go
rename to internal/cmd/agent/deployer/internal/scheme/scheme.go
diff --git a/modules/agent/pkg/deployer/manager.go b/internal/cmd/agent/deployer/manager.go
similarity index 98%
rename from modules/agent/pkg/deployer/manager.go
rename to internal/cmd/agent/deployer/manager.go
index a2c3ac29..d8c190b3 100644
--- a/modules/agent/pkg/deployer/manager.go
+++ b/internal/cmd/agent/deployer/manager.go
@@ -3,10 +3,10 @@ package deployer
 import (
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/helmdeployer"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	"github.com/rancher/fleet/pkg/manifest"
 	"github.com/rancher/wrangler/pkg/apply"
 	"github.com/rancher/wrangler/pkg/kv"
 	apierror "k8s.io/apimachinery/pkg/api/errors"
diff --git a/modules/agent/pkg/deployer/monitor.go b/internal/cmd/agent/deployer/monitor.go
similarity index 96%
rename from modules/agent/pkg/deployer/monitor.go
rename to internal/cmd/agent/deployer/monitor.go
index 7e20a029..ac02917a 100644
--- a/modules/agent/pkg/deployer/monitor.go
+++ b/internal/cmd/agent/deployer/monitor.go
@@ -8,12 +8,12 @@ import (
 	jsonpatch "github.com/evanphx/json-patch"
 
 	"github.com/pkg/errors"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/diff"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/diffnormalize"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/resource"
-	fleetnorm "github.com/rancher/fleet/modules/agent/pkg/deployer/normalizers"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/diff"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/diffnormalize"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/resource"
+	fleetnorm "github.com/rancher/fleet/internal/cmd/agent/deployer/normalizers"
+	"github.com/rancher/fleet/internal/helmdeployer"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
 	"github.com/rancher/wrangler/pkg/apply"
 	"github.com/rancher/wrangler/pkg/merr"
 	"github.com/rancher/wrangler/pkg/objectset"
diff --git a/modules/agent/pkg/deployer/monitor_test.go b/internal/cmd/agent/deployer/monitor_test.go
similarity index 100%
rename from modules/agent/pkg/deployer/monitor_test.go
rename to internal/cmd/agent/deployer/monitor_test.go
diff --git a/modules/agent/pkg/deployer/normalizers/jsonpatch.go b/internal/cmd/agent/deployer/normalizers/jsonpatch.go
similarity index 100%
rename from modules/agent/pkg/deployer/normalizers/jsonpatch.go
rename to internal/cmd/agent/deployer/normalizers/jsonpatch.go
diff --git a/modules/agent/pkg/deployer/normalizers/mutatingwebhook.go b/internal/cmd/agent/deployer/normalizers/mutatingwebhook.go
similarity index 100%
rename from modules/agent/pkg/deployer/normalizers/mutatingwebhook.go
rename to internal/cmd/agent/deployer/normalizers/mutatingwebhook.go
diff --git a/modules/agent/pkg/deployer/normalizers/norm.go b/internal/cmd/agent/deployer/normalizers/norm.go
similarity index 90%
rename from modules/agent/pkg/deployer/normalizers/norm.go
rename to internal/cmd/agent/deployer/normalizers/norm.go
index 73c25495..3b34f07f 100644
--- a/modules/agent/pkg/deployer/normalizers/norm.go
+++ b/internal/cmd/agent/deployer/normalizers/norm.go
@@ -1,7 +1,7 @@
 package normalizers
 
 import (
-	"github.com/rancher/fleet/modules/agent/pkg/deployer/internal/diff"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer/internal/diff"
 	"github.com/rancher/wrangler/pkg/objectset"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 )
diff --git a/modules/agent/pkg/deployer/normalizers/validatingwebhook.go b/internal/cmd/agent/deployer/normalizers/validatingwebhook.go
similarity index 100%
rename from modules/agent/pkg/deployer/normalizers/validatingwebhook.go
rename to internal/cmd/agent/deployer/normalizers/validatingwebhook.go
diff --git a/modules/agent/pkg/globals/globals.go b/internal/cmd/agent/globals/globals.go
similarity index 100%
rename from modules/agent/pkg/globals/globals.go
rename to internal/cmd/agent/globals/globals.go
diff --git a/modules/agent/pkg/register/register.go b/internal/cmd/agent/register/register.go
similarity index 99%
rename from modules/agent/pkg/register/register.go
rename to internal/cmd/agent/register/register.go
index 32572ecd..8f3f04a4 100644
--- a/modules/agent/pkg/register/register.go
+++ b/internal/cmd/agent/register/register.go
@@ -8,11 +8,11 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/config"
+	"github.com/rancher/fleet/internal/registration"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
-	"github.com/rancher/fleet/pkg/registration"
 
 	"github.com/rancher/wrangler/pkg/generated/controllers/core"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
diff --git a/modules/agent/cmds/root.go b/internal/cmd/agent/root.go
similarity index 87%
rename from modules/agent/cmds/root.go
rename to internal/cmd/agent/root.go
index 1a99502b..6326a7ed 100644
--- a/modules/agent/cmds/root.go
+++ b/internal/cmd/agent/root.go
@@ -1,4 +1,4 @@
-package cmds
+package agent
 
 import (
 	"fmt"
@@ -8,7 +8,6 @@ import (
 
 	"github.com/spf13/cobra"
 
-	"github.com/rancher/fleet/modules/agent/pkg/agent"
 	"github.com/rancher/fleet/pkg/version"
 
 	command "github.com/rancher/wrangler-cli"
@@ -32,7 +31,7 @@ func (a *FleetAgent) Run(cmd *cobra.Command, args []string) error {
 
 	debugConfig.MustSetupDebug()
 	var (
-		opts agent.Options
+		opts options
 		err  error
 	)
 
@@ -45,7 +44,7 @@ func (a *FleetAgent) Run(cmd *cobra.Command, args []string) error {
 	if a.Namespace == "" {
 		return fmt.Errorf("--namespace or env NAMESPACE is required to be set")
 	}
-	if err := agent.Start(cmd.Context(), a.Kubeconfig, a.Namespace, a.AgentScope, &opts); err != nil {
+	if err := start(cmd.Context(), a.Kubeconfig, a.Namespace, a.AgentScope, &opts); err != nil {
 		return err
 	}
 	<-cmd.Context().Done()
diff --git a/modules/agent/pkg/agent/app.go b/internal/cmd/agent/start.go
similarity index 80%
rename from modules/agent/pkg/agent/app.go
rename to internal/cmd/agent/start.go
index 718e7e5c..154a1d49 100644
--- a/modules/agent/pkg/agent/app.go
+++ b/internal/cmd/agent/start.go
@@ -1,4 +1,3 @@
-// Package agent provides the agent controller. (fleetagent)
 package agent
 
 import (
@@ -6,8 +5,8 @@ import (
 	"sync"
 	"time"
 
-	"github.com/rancher/fleet/modules/agent/pkg/controllers"
-	"github.com/rancher/fleet/modules/agent/pkg/register"
+	"github.com/rancher/fleet/internal/cmd/agent/controllers"
+	"github.com/rancher/fleet/internal/cmd/agent/register"
 
 	"github.com/rancher/lasso/pkg/mapper"
 	"github.com/rancher/wrangler/pkg/kubeconfig"
@@ -22,16 +21,16 @@ import (
 	"k8s.io/client-go/tools/clientcmd"
 )
 
-type Options struct {
+type options struct {
 	DefaultNamespace string
 	ClusterID        string
 	CheckinInterval  time.Duration
 }
 
-// Start the fleet agent
-func Start(ctx context.Context, kubeConfig, namespace, agentScope string, opts *Options) error {
+// start the fleet agent
+func start(ctx context.Context, kubeConfig, namespace, agentScope string, opts *options) error {
 	if opts == nil {
-		opts = &Options{}
+		opts = &options{}
 	}
 	if opts.DefaultNamespace == "" {
 		opts.DefaultNamespace = "default"
@@ -58,7 +57,7 @@ func Start(ctx context.Context, kubeConfig, namespace, agentScope string, opts *
 		return err
 	}
 
-	fleetMapper, mapper, discovery, err := NewMappers(ctx, fleetRestConfig, clientConfig, opts)
+	fleetMapper, mapper, discovery, err := newMappers(ctx, fleetRestConfig, clientConfig)
 	if err != nil {
 		return err
 	}
@@ -86,7 +85,7 @@ var (
 )
 
 // Share mappers across simulators
-func NewMappers(ctx context.Context, fleetRESTConfig *rest.Config, clientconfig clientcmd.ClientConfig, opts *Options) (meta.RESTMapper, meta.RESTMapper, discovery.CachedDiscoveryInterface, error) {
+func newMappers(ctx context.Context, fleetRESTConfig *rest.Config, clientconfig clientcmd.ClientConfig) (meta.RESTMapper, meta.RESTMapper, discovery.CachedDiscoveryInterface, error) {
 	mapperLock.Lock()
 	defer mapperLock.Unlock()
 
diff --git a/modules/agent/pkg/trigger/watcher.go b/internal/cmd/agent/trigger/watcher.go
similarity index 98%
rename from modules/agent/pkg/trigger/watcher.go
rename to internal/cmd/agent/trigger/watcher.go
index e7f603ed..7f4b9d0f 100644
--- a/modules/agent/pkg/trigger/watcher.go
+++ b/internal/cmd/agent/trigger/watcher.go
@@ -1,4 +1,4 @@
-// Package trigger watches a set of deployed resources and triggers a callback when one of them is deleted. (fleetagent)
+// Package trigger watches a set of deployed resources and triggers a callback when one of them is deleted.
 package trigger
 
 import (
diff --git a/modules/cli/cmds/apply.go b/internal/cmd/cli/apply.go
similarity index 97%
rename from modules/cli/cmds/apply.go
rename to internal/cmd/cli/apply.go
index 78d99040..b7dab4da 100644
--- a/modules/cli/cmds/apply.go
+++ b/internal/cmd/cli/apply.go
@@ -1,4 +1,4 @@
-package cmds
+package cli
 
 import (
 	"bytes"
@@ -9,9 +9,9 @@ import (
 
 	"github.com/spf13/cobra"
 
-	"github.com/rancher/fleet/modules/cli/apply"
-	"github.com/rancher/fleet/modules/cli/pkg/writer"
-	"github.com/rancher/fleet/pkg/bundlereader"
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
+	"github.com/rancher/fleet/internal/cmd/cli/writer"
 	command "github.com/rancher/wrangler-cli"
 	"github.com/rancher/wrangler/pkg/yaml"
 )
diff --git a/modules/cli/apply/apply.go b/internal/cmd/cli/apply/apply.go
similarity index 98%
rename from modules/cli/apply/apply.go
rename to internal/cmd/cli/apply/apply.go
index 68e87288..b568b846 100644
--- a/modules/cli/apply/apply.go
+++ b/internal/cmd/cli/apply/apply.go
@@ -1,4 +1,4 @@
-// Package apply creates bundle resources from gitrepo resources (fleetapply)
+// Package apply creates bundle resources from gitrepo resources.
 package apply
 
 import (
@@ -13,11 +13,11 @@ import (
 
 	"github.com/sirupsen/logrus"
 
-	"github.com/rancher/fleet/modules/cli/pkg/client"
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/client"
+	"github.com/rancher/fleet/internal/fleetyaml"
+	name2 "github.com/rancher/fleet/internal/name"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/bundlereader"
-	"github.com/rancher/fleet/pkg/fleetyaml"
-	name2 "github.com/rancher/fleet/pkg/name"
 
 	"github.com/rancher/wrangler/pkg/yaml"
 
diff --git a/modules/cli/match/match.go b/internal/cmd/cli/match/match.go
similarity index 88%
rename from modules/cli/match/match.go
rename to internal/cmd/cli/match/match.go
index 2be9a3cc..50b6f566 100644
--- a/modules/cli/match/match.go
+++ b/internal/cmd/cli/match/match.go
@@ -1,4 +1,4 @@
-// Package match is used to test matching a bundles to a target on the command line. (fleetapply)
+// Package match is used to test matching a bundles to a target on the command line.
 //
 // It's not used by fleet, but it is available in the fleet CLI as "test" sub
 // command. The tests in fleet-examples use it.
@@ -12,12 +12,12 @@ import (
 	"io"
 	"os"
 
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/cmd/controller/options"
+	"github.com/rancher/fleet/internal/cmd/controller/target/matcher"
+	"github.com/rancher/fleet/internal/helmdeployer"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/bundlereader"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	"github.com/rancher/fleet/pkg/manifest"
-	"github.com/rancher/fleet/pkg/options"
-	"github.com/rancher/fleet/pkg/target/matcher"
 
 	"github.com/rancher/wrangler/pkg/yaml"
 )
diff --git a/modules/cli/cmds/root.go b/internal/cmd/cli/root.go
similarity index 91%
rename from modules/cli/cmds/root.go
rename to internal/cmd/cli/root.go
index e9d4eb9b..ee64abe4 100644
--- a/modules/cli/cmds/root.go
+++ b/internal/cmd/cli/root.go
@@ -1,10 +1,10 @@
-// Package cmds sets up the CLI commands for the fleet apply binary. (fleetapply)
-package cmds
+// Package cli sets up the CLI commands for the fleet apply binary.
+package cli
 
 import (
 	"github.com/spf13/cobra"
 
-	"github.com/rancher/fleet/modules/cli/pkg/client"
+	"github.com/rancher/fleet/internal/client"
 	"github.com/rancher/fleet/pkg/version"
 
 	command "github.com/rancher/wrangler-cli"
diff --git a/modules/cli/pkg/writer/writer.go b/internal/cmd/cli/writer/writer.go
similarity index 96%
rename from modules/cli/pkg/writer/writer.go
rename to internal/cmd/cli/writer/writer.go
index 7c7295da..c0e49680 100644
--- a/modules/cli/pkg/writer/writer.go
+++ b/internal/cmd/cli/writer/writer.go
@@ -1,4 +1,4 @@
-// Package writer provides a writer that can be used to write to a file or stdout. (fleetapply)
+// Package writer provides a writer that can be used to write to a file or stdout.
 package writer
 
 import (
diff --git a/pkg/agent/agent.go b/internal/cmd/controller/agent/agent.go
similarity index 97%
rename from pkg/agent/agent.go
rename to internal/cmd/controller/agent/agent.go
index 9e08b890..1679e7a3 100644
--- a/pkg/agent/agent.go
+++ b/internal/cmd/controller/agent/agent.go
@@ -1,4 +1,4 @@
-// Package agent builds manifests for creating a managed fleet-agent. (fleetcontroller)
+// Package agent builds manifests for creating a managed fleet-agent.
 package agent
 
 import (
@@ -6,12 +6,12 @@ import (
 	"fmt"
 	"time"
 
-	"github.com/rancher/fleet/modules/cli/pkg/client"
+	"github.com/rancher/fleet/internal/client"
+	fleetns "github.com/rancher/fleet/internal/cmd/controller/namespace"
+	"github.com/rancher/fleet/internal/config"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	fleetns "github.com/rancher/fleet/pkg/namespace"
 
 	"github.com/rancher/wrangler/pkg/yaml"
 
diff --git a/pkg/agent/config.go b/internal/cmd/controller/agent/config.go
similarity index 93%
rename from pkg/agent/config.go
rename to internal/cmd/controller/agent/config.go
index dc54549c..b8ad7b26 100644
--- a/pkg/agent/config.go
+++ b/internal/cmd/controller/agent/config.go
@@ -3,8 +3,8 @@ package agent
 import (
 	"context"
 
-	"github.com/rancher/fleet/modules/cli/pkg/client"
-	"github.com/rancher/fleet/pkg/config"
+	"github.com/rancher/fleet/internal/client"
+	"github.com/rancher/fleet/internal/config"
 
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
diff --git a/pkg/agent/manifest.go b/internal/cmd/controller/agent/manifest.go
similarity index 99%
rename from pkg/agent/manifest.go
rename to internal/cmd/controller/agent/manifest.go
index c9b73fe3..32e8622b 100644
--- a/pkg/agent/manifest.go
+++ b/internal/cmd/controller/agent/manifest.go
@@ -8,7 +8,7 @@ import (
 
 	"github.com/sirupsen/logrus"
 
-	"github.com/rancher/fleet/pkg/config"
+	"github.com/rancher/fleet/internal/config"
 	"github.com/rancher/wrangler/pkg/name"
 
 	appsv1 "k8s.io/api/apps/v1"
diff --git a/pkg/agent/manifest_test.go b/internal/cmd/controller/agent/manifest_test.go
similarity index 100%
rename from pkg/agent/manifest_test.go
rename to internal/cmd/controller/agent/manifest_test.go
diff --git a/pkg/connection/connection.go b/internal/cmd/controller/connection/connection.go
similarity index 82%
rename from pkg/connection/connection.go
rename to internal/cmd/controller/connection/connection.go
index 2942db44..87a05bdf 100644
--- a/pkg/connection/connection.go
+++ b/internal/cmd/controller/connection/connection.go
@@ -1,4 +1,4 @@
-// Package connection provides a connection to a Kubernetes cluster, used when importing a cluster. (fleetcontroller)
+// Package connection provides a connection to a Kubernetes cluster, used when importing a cluster.
 package connection
 
 import (
diff --git a/pkg/controllers/bootstrap/bootstrap.go b/internal/cmd/controller/controllers/bootstrap/bootstrap.go
similarity index 97%
rename from pkg/controllers/bootstrap/bootstrap.go
rename to internal/cmd/controller/controllers/bootstrap/bootstrap.go
index e8669a97..f43b95e7 100644
--- a/pkg/controllers/bootstrap/bootstrap.go
+++ b/internal/cmd/controller/controllers/bootstrap/bootstrap.go
@@ -8,10 +8,10 @@ import (
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 
+	fleetns "github.com/rancher/fleet/internal/cmd/controller/namespace"
+	secretutil "github.com/rancher/fleet/internal/cmd/controller/secret"
+	"github.com/rancher/fleet/internal/config"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
-	fleetns "github.com/rancher/fleet/pkg/namespace"
-	secretutil "github.com/rancher/fleet/pkg/secret"
 	"github.com/rancher/wrangler/pkg/apply"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
 
diff --git a/pkg/controllers/bundle/controller.go b/internal/cmd/controller/controllers/bundle/controller.go
similarity index 97%
rename from pkg/controllers/bundle/controller.go
rename to internal/cmd/controller/controllers/bundle/controller.go
index bd808b28..c4280f60 100644
--- a/pkg/controllers/bundle/controller.go
+++ b/internal/cmd/controller/controllers/bundle/controller.go
@@ -1,4 +1,4 @@
-// Package bundle registers a controller for Bundle objects. (fleetcontroller)
+// Package bundle registers a controller for Bundle objects.
 package bundle
 
 import (
@@ -9,13 +9,13 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/cmd/controller/options"
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
+	"github.com/rancher/fleet/internal/cmd/controller/target"
+	"github.com/rancher/fleet/internal/helmdeployer"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	"github.com/rancher/fleet/pkg/manifest"
-	"github.com/rancher/fleet/pkg/options"
-	"github.com/rancher/fleet/pkg/summary"
-	"github.com/rancher/fleet/pkg/target"
 
 	"github.com/rancher/wrangler/pkg/apply"
 	"github.com/rancher/wrangler/pkg/generic"
diff --git a/pkg/controllers/cleanup/handler.go b/internal/cmd/controller/controllers/cleanup/handler.go
similarity index 98%
rename from pkg/controllers/cleanup/handler.go
rename to internal/cmd/controller/controllers/cleanup/handler.go
index ece1dfeb..f0b2b2cc 100644
--- a/pkg/controllers/cleanup/handler.go
+++ b/internal/cmd/controller/controllers/cleanup/handler.go
@@ -1,4 +1,4 @@
-// Package cleanup provides a controller that cleans up resources that are no longer needed. (fleetcontroller)
+// Package cleanup provides a controller that cleans up resources that are no longer needed.
 package cleanup
 
 import (
diff --git a/pkg/controllers/cluster/controller.go b/internal/cmd/controller/controllers/cluster/controller.go
similarity index 97%
rename from pkg/controllers/cluster/controller.go
rename to internal/cmd/controller/controllers/cluster/controller.go
index d91eb3ef..4dd576a5 100644
--- a/pkg/controllers/cluster/controller.go
+++ b/internal/cmd/controller/controllers/cluster/controller.go
@@ -1,4 +1,4 @@
-// Package cluster provides controllers for managing clusters: status changes, importing, bootstrapping. (fleetcontroller)
+// Package cluster provides controllers for managing clusters: status changes, importing, bootstrapping.
 package cluster
 
 import (
@@ -7,10 +7,10 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/clusterregistration"
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/controllers/clusterregistration"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/summary"
 
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
 	"github.com/rancher/wrangler/pkg/kv"
diff --git a/pkg/controllers/cluster/import.go b/internal/cmd/controller/controllers/cluster/import.go
similarity index 97%
rename from pkg/controllers/cluster/import.go
rename to internal/cmd/controller/controllers/cluster/import.go
index 4c0ffcfa..d2a08c75 100644
--- a/pkg/controllers/cluster/import.go
+++ b/internal/cmd/controller/controllers/cluster/import.go
@@ -9,16 +9,16 @@ import (
 
 	"github.com/sirupsen/logrus"
 
-	"github.com/rancher/fleet/modules/cli/pkg/client"
-	"github.com/rancher/fleet/pkg/agent"
+	"github.com/rancher/fleet/internal/client"
+	"github.com/rancher/fleet/internal/cmd/controller/agent"
+	"github.com/rancher/fleet/internal/cmd/controller/connection"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/manageagent"
+	fleetns "github.com/rancher/fleet/internal/cmd/controller/namespace"
+	"github.com/rancher/fleet/internal/config"
+	"github.com/rancher/fleet/internal/helmdeployer"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
-	"github.com/rancher/fleet/pkg/connection"
-	"github.com/rancher/fleet/pkg/controllers/manageagent"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	fleetns "github.com/rancher/fleet/pkg/namespace"
 	"github.com/rancher/wrangler/pkg/apply"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
 	"github.com/rancher/wrangler/pkg/name"
diff --git a/pkg/controllers/clustergroup/controller.go b/internal/cmd/controller/controllers/clustergroup/controller.go
similarity index 97%
rename from pkg/controllers/clustergroup/controller.go
rename to internal/cmd/controller/controllers/clustergroup/controller.go
index eed15603..b5efe28e 100644
--- a/pkg/controllers/clustergroup/controller.go
+++ b/internal/cmd/controller/controllers/clustergroup/controller.go
@@ -1,4 +1,4 @@
-// Package clustergroup provides a controller to update the ClusterGroup resource status. (fleetcontroller)
+// Package clustergroup provides a controller to update the ClusterGroup resource status.
 package clustergroup
 
 import (
@@ -7,9 +7,9 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/summary"
 
 	"github.com/rancher/wrangler/pkg/kv"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
diff --git a/pkg/controllers/clusterregistration/controller.go b/internal/cmd/controller/controllers/clusterregistration/controller.go
similarity index 98%
rename from pkg/controllers/clusterregistration/controller.go
rename to internal/cmd/controller/controllers/clusterregistration/controller.go
index e2ec1c5b..a2382f3c 100644
--- a/pkg/controllers/clusterregistration/controller.go
+++ b/internal/cmd/controller/controllers/clusterregistration/controller.go
@@ -1,4 +1,4 @@
-// Package clusterregistration implements manager-initiated and agent-initiated registration. (fleetcontroller)
+// Package clusterregistration implements manager-initiated and agent-initiated registration.
 //
 // Add or import downstream clusters / agents to Fleet and keep information
 // from their registration (e.g. local cluster kubeconfig) up-to-date.
@@ -13,13 +13,13 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	secretutil "github.com/rancher/fleet/internal/cmd/controller/secret"
+	"github.com/rancher/fleet/internal/config"
+	"github.com/rancher/fleet/internal/registration"
 	fleetgroup "github.com/rancher/fleet/pkg/apis/fleet.cattle.io"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/registration"
-	secretutil "github.com/rancher/fleet/pkg/secret"
 
 	"github.com/rancher/wrangler/pkg/apply"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
diff --git a/pkg/controllers/clusterregistrationtoken/handler.go b/internal/cmd/controller/controllers/clusterregistrationtoken/handler.go
similarity index 98%
rename from pkg/controllers/clusterregistrationtoken/handler.go
rename to internal/cmd/controller/controllers/clusterregistrationtoken/handler.go
index 9c3b4bb1..c3e98675 100644
--- a/pkg/controllers/clusterregistrationtoken/handler.go
+++ b/internal/cmd/controller/controllers/clusterregistrationtoken/handler.go
@@ -1,4 +1,4 @@
-// Package clusterregistrationtoken provides a controller for ClusterRegistrationToken. (fleetcontroller)
+// Package clusterregistrationtoken provides a controller for ClusterRegistrationToken.
 //
 // It creates a service account and role binding for the token.
 package clusterregistrationtoken
@@ -9,11 +9,11 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	secretutil "github.com/rancher/fleet/internal/cmd/controller/secret"
+	"github.com/rancher/fleet/internal/config"
 	fleetgroup "github.com/rancher/fleet/pkg/apis/fleet.cattle.io"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	secretutil "github.com/rancher/fleet/pkg/secret"
 
 	"github.com/rancher/wrangler/pkg/apply"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
diff --git a/pkg/controllers/config/controller.go b/internal/cmd/controller/controllers/config/controller.go
similarity index 88%
rename from pkg/controllers/config/controller.go
rename to internal/cmd/controller/controllers/config/controller.go
index fd14a16a..1b646d4d 100644
--- a/pkg/controllers/config/controller.go
+++ b/internal/cmd/controller/controllers/config/controller.go
@@ -1,10 +1,10 @@
-// Package config reads the initial global configuration. (fleetcontroller)
+// Package config reads the initial global configuration.
 package config
 
 import (
 	"context"
 
-	"github.com/rancher/fleet/pkg/config"
+	"github.com/rancher/fleet/internal/config"
 
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
 
diff --git a/pkg/controllers/content/controller.go b/internal/cmd/controller/controllers/content/controller.go
similarity index 97%
rename from pkg/controllers/content/controller.go
rename to internal/cmd/controller/controllers/content/controller.go
index 603193f9..058065be 100644
--- a/pkg/controllers/content/controller.go
+++ b/internal/cmd/controller/controllers/content/controller.go
@@ -1,4 +1,4 @@
-// Package content purges orphaned content objects by inspecting bundledeployments in all namespaces. Runs every 5 minutes. (fleetcontroller)
+// Package content purges orphaned content objects by inspecting bundledeployments in all namespaces. Runs every 5 minutes.
 package content
 
 import (
diff --git a/pkg/controllers/controllers.go b/internal/cmd/controller/controllers/controllers.go
similarity index 88%
rename from pkg/controllers/controllers.go
rename to internal/cmd/controller/controllers/controllers.go
index 3fe3be5f..8afd0bd5 100644
--- a/pkg/controllers/controllers.go
+++ b/internal/cmd/controller/controllers/controllers.go
@@ -1,4 +1,4 @@
-// Package controllers sets up the controllers for the fleet-controller. (fleetcontroller)
+// Package controllers sets up the controllers for the fleet-controller.
 package controllers
 
 import (
@@ -8,25 +8,25 @@ import (
 	"github.com/sirupsen/logrus"
 	"k8s.io/apimachinery/pkg/runtime/schema"
 
-	"github.com/rancher/fleet/pkg/controllers/bootstrap"
-	"github.com/rancher/fleet/pkg/controllers/bundle"
-	"github.com/rancher/fleet/pkg/controllers/cleanup"
-	"github.com/rancher/fleet/pkg/controllers/cluster"
-	"github.com/rancher/fleet/pkg/controllers/clustergroup"
-	"github.com/rancher/fleet/pkg/controllers/clusterregistration"
-	"github.com/rancher/fleet/pkg/controllers/clusterregistrationtoken"
-	"github.com/rancher/fleet/pkg/controllers/config"
-	"github.com/rancher/fleet/pkg/controllers/content"
-	"github.com/rancher/fleet/pkg/controllers/display"
-	"github.com/rancher/fleet/pkg/controllers/git"
-	"github.com/rancher/fleet/pkg/controllers/image"
-	"github.com/rancher/fleet/pkg/controllers/manageagent"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/bootstrap"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/bundle"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/cleanup"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/cluster"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/clustergroup"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/clusterregistration"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/clusterregistrationtoken"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/config"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/content"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/display"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/git"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/image"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/manageagent"
+	fleetns "github.com/rancher/fleet/internal/cmd/controller/namespace"
+	"github.com/rancher/fleet/internal/cmd/controller/target"
+	"github.com/rancher/fleet/internal/manifest"
 	"github.com/rancher/fleet/pkg/durations"
 	"github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/manifest"
-	fleetns "github.com/rancher/fleet/pkg/namespace"
-	"github.com/rancher/fleet/pkg/target"
 
 	"github.com/rancher/gitjob/pkg/generated/controllers/gitjob.cattle.io"
 	gitcontrollers "github.com/rancher/gitjob/pkg/generated/controllers/gitjob.cattle.io/v1"
diff --git a/pkg/controllers/data.go b/internal/cmd/controller/controllers/data.go
similarity index 95%
rename from pkg/controllers/data.go
rename to internal/cmd/controller/controllers/data.go
index 38a45304..42e8bc22 100644
--- a/pkg/controllers/data.go
+++ b/internal/cmd/controller/controllers/data.go
@@ -1,9 +1,9 @@
 package controllers
 
 import (
+	fleetns "github.com/rancher/fleet/internal/cmd/controller/namespace"
 	fleetgroup "github.com/rancher/fleet/pkg/apis/fleet.cattle.io"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	fleetns "github.com/rancher/fleet/pkg/namespace"
 	corev1 "k8s.io/api/core/v1"
 	rbacv1 "k8s.io/api/rbac/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
diff --git a/pkg/controllers/display/displaycontrollers.go b/internal/cmd/controller/controllers/display/displaycontrollers.go
similarity index 98%
rename from pkg/controllers/display/displaycontrollers.go
rename to internal/cmd/controller/controllers/display/displaycontrollers.go
index 352e355a..afa95021 100644
--- a/pkg/controllers/display/displaycontrollers.go
+++ b/internal/cmd/controller/controllers/display/displaycontrollers.go
@@ -1,4 +1,4 @@
-// Package display provides controllers that update the status fields on several resources. (fleetcontroller)
+// Package display provides controllers that update the status fields on several resources.
 package display
 
 import (
@@ -6,9 +6,9 @@ import (
 	"fmt"
 	"strings"
 
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/summary"
 	"github.com/sirupsen/logrus"
 
 	"github.com/rancher/wrangler/pkg/genericcondition"
diff --git a/pkg/controllers/git/git.go b/internal/cmd/controller/controllers/git/git.go
similarity index 98%
rename from pkg/controllers/git/git.go
rename to internal/cmd/controller/controllers/git/git.go
index bd422a93..e6ed37e8 100644
--- a/pkg/controllers/git/git.go
+++ b/internal/cmd/controller/controllers/git/git.go
@@ -13,12 +13,12 @@ import (
 
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/clusterregistration"
+	"github.com/rancher/fleet/internal/cmd/controller/display"
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
+	"github.com/rancher/fleet/internal/config"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
-	"github.com/rancher/fleet/pkg/controllers/clusterregistration"
-	"github.com/rancher/fleet/pkg/display"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/summary"
 
 	gitjob "github.com/rancher/gitjob/pkg/apis/gitjob.cattle.io/v1"
 	v1 "github.com/rancher/gitjob/pkg/generated/controllers/gitjob.cattle.io/v1"
diff --git a/pkg/controllers/image/image.go b/internal/cmd/controller/controllers/image/image.go
similarity index 99%
rename from pkg/controllers/image/image.go
rename to internal/cmd/controller/controllers/image/image.go
index ae0c4760..8aaaa6ac 100644
--- a/pkg/controllers/image/image.go
+++ b/internal/cmd/controller/controllers/image/image.go
@@ -1,4 +1,4 @@
-// Package image registers a controller for image scans. (fleetcontroller)
+// Package image registers a controller for image scans.
 package image
 
 import (
@@ -28,10 +28,10 @@ import (
 	"github.com/google/go-containerregistry/pkg/v1/remote"
 	"github.com/sirupsen/logrus"
 
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/image/update"
 	"github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	"github.com/rancher/fleet/pkg/durations"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/update"
 
 	"github.com/rancher/wrangler/pkg/condition"
 	corev1controller "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
diff --git a/pkg/update/README.md b/internal/cmd/controller/controllers/image/update/README.md
similarity index 100%
rename from pkg/update/README.md
rename to internal/cmd/controller/controllers/image/update/README.md
diff --git a/pkg/update/filereader.go b/internal/cmd/controller/controllers/image/update/filereader.go
similarity index 100%
rename from pkg/update/filereader.go
rename to internal/cmd/controller/controllers/image/update/filereader.go
diff --git a/pkg/update/filter.go b/internal/cmd/controller/controllers/image/update/filter.go
similarity index 100%
rename from pkg/update/filter.go
rename to internal/cmd/controller/controllers/image/update/filter.go
diff --git a/pkg/update/result.go b/internal/cmd/controller/controllers/image/update/result.go
similarity index 100%
rename from pkg/update/result.go
rename to internal/cmd/controller/controllers/image/update/result.go
diff --git a/pkg/update/setters.go b/internal/cmd/controller/controllers/image/update/setters.go
similarity index 100%
rename from pkg/update/setters.go
rename to internal/cmd/controller/controllers/image/update/setters.go
diff --git a/pkg/controllers/manageagent/manageagent.go b/internal/cmd/controller/controllers/manageagent/manageagent.go
similarity index 98%
rename from pkg/controllers/manageagent/manageagent.go
rename to internal/cmd/controller/controllers/manageagent/manageagent.go
index 0a229101..f7f42f71 100644
--- a/pkg/controllers/manageagent/manageagent.go
+++ b/internal/cmd/controller/controllers/manageagent/manageagent.go
@@ -1,4 +1,4 @@
-// Package manageagent provides a controller for managing the agent bundle. (fleetcontroller)
+// Package manageagent provides a controller for managing the agent bundle.
 //
 // Allows Fleet to deploy the Fleet Agent itself as a Bundle, which ensures
 // changes to Fleet’s configuration are reflected in the Agent.
@@ -11,9 +11,9 @@ import (
 	"encoding/json"
 	"fmt"
 
-	"github.com/rancher/fleet/pkg/agent"
+	"github.com/rancher/fleet/internal/cmd/controller/agent"
+	"github.com/rancher/fleet/internal/config"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/config"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
 	"github.com/sirupsen/logrus"
 
diff --git a/pkg/display/gitrepo.go b/internal/cmd/controller/display/gitrepo.go
similarity index 99%
rename from pkg/display/gitrepo.go
rename to internal/cmd/controller/display/gitrepo.go
index a979f074..9b3acd2e 100644
--- a/pkg/display/gitrepo.go
+++ b/internal/cmd/controller/display/gitrepo.go
@@ -1,4 +1,4 @@
-// Package display accumulates the resources for the gitrepo status from bundles. (fleetcontroller)
+// Package display accumulates the resources for the gitrepo status from bundles.
 package display
 
 import (
diff --git a/internal/mocks/namespace_mock.go b/internal/cmd/controller/mocks/namespace_mock.go
similarity index 100%
rename from internal/mocks/namespace_mock.go
rename to internal/cmd/controller/mocks/namespace_mock.go
diff --git a/pkg/namespace/util.go b/internal/cmd/controller/namespace/util.go
similarity index 97%
rename from pkg/namespace/util.go
rename to internal/cmd/controller/namespace/util.go
index 8c798c07..c8a36892 100644
--- a/pkg/namespace/util.go
+++ b/internal/cmd/controller/namespace/util.go
@@ -1,4 +1,4 @@
-// Package namespace generates the name of the system registration namespace. (fleetcontroller)
+// Package namespace generates the name of the system registration namespace.
 //
 // Special namespaces in fleet:
 // * system namespace: cattle-fleet-system
diff --git a/pkg/options/calculate.go b/internal/cmd/controller/options/calculate.go
similarity index 98%
rename from pkg/options/calculate.go
rename to internal/cmd/controller/options/calculate.go
index 19d5bfc9..4ae8a543 100644
--- a/pkg/options/calculate.go
+++ b/internal/cmd/controller/options/calculate.go
@@ -6,8 +6,8 @@ import (
 	"encoding/hex"
 	"encoding/json"
 
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/manifest"
 	"github.com/rancher/wrangler/pkg/data"
 )
 
diff --git a/modules/controller/cmds/root.go b/internal/cmd/controller/root.go
similarity index 92%
rename from modules/controller/cmds/root.go
rename to internal/cmd/controller/root.go
index 93fd3131..01ee5eb0 100644
--- a/modules/controller/cmds/root.go
+++ b/internal/cmd/controller/root.go
@@ -1,3 +1,4 @@
+// Package controller starts the fleet controller.
 package controller
 
 import (
@@ -13,9 +14,8 @@ import (
 
 	"k8s.io/apimachinery/pkg/util/wait"
 
-	"github.com/rancher/fleet/pkg/agent"
+	"github.com/rancher/fleet/internal/cmd/controller/agent"
 	"github.com/rancher/fleet/pkg/durations"
-	"github.com/rancher/fleet/pkg/fleetcontroller"
 	"github.com/rancher/fleet/pkg/version"
 
 	command "github.com/rancher/wrangler-cli"
@@ -38,7 +38,7 @@ func (f *FleetManager) Run(cmd *cobra.Command, args []string) error {
 		log.Println(http.ListenAndServe("localhost:6060", nil)) // nolint:gosec // Debugging only
 	}()
 	debugConfig.MustSetupDebug()
-	if err := fleetcontroller.Start(cmd.Context(), f.Namespace, f.Kubeconfig, f.DisableGitops, f.DisableBootstrap); err != nil {
+	if err := start(cmd.Context(), f.Namespace, f.Kubeconfig, f.DisableGitops, f.DisableBootstrap); err != nil {
 		return err
 	}
 
diff --git a/pkg/secret/util.go b/internal/cmd/controller/secret/util.go
similarity index 98%
rename from pkg/secret/util.go
rename to internal/cmd/controller/secret/util.go
index d39ae74f..3e5899bb 100644
--- a/pkg/secret/util.go
+++ b/internal/cmd/controller/secret/util.go
@@ -1,4 +1,4 @@
-// Package secret gets or creates service account secrets for cluster registration. (fleetcontroller)
+// Package secret gets or creates service account secrets for cluster registration.
 package secret
 
 import (
diff --git a/pkg/fleetcontroller/app.go b/internal/cmd/controller/start.go
similarity index 73%
rename from pkg/fleetcontroller/app.go
rename to internal/cmd/controller/start.go
index 4e869352..0ad615dc 100644
--- a/pkg/fleetcontroller/app.go
+++ b/internal/cmd/controller/start.go
@@ -1,17 +1,16 @@
-// Package fleetcontroller registers the fleet controller. (fleetcontroller)
-package fleetcontroller
+package controller
 
 import (
 	"context"
 
-	"github.com/rancher/fleet/pkg/controllers"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers"
 	"github.com/rancher/fleet/pkg/crd"
 
 	"github.com/rancher/wrangler/pkg/kubeconfig"
 	"github.com/rancher/wrangler/pkg/ratelimit"
 )
 
-func Start(ctx context.Context, systemNamespace string, kubeconfigFile string, disableGitops bool, disableBootstrap bool) error {
+func start(ctx context.Context, systemNamespace string, kubeconfigFile string, disableGitops bool, disableBootstrap bool) error {
 	cfg := kubeconfig.GetNonInteractiveClientConfig(kubeconfigFile)
 	clientConfig, err := cfg.ClientConfig()
 	if err != nil {
diff --git a/pkg/summary/summary.go b/internal/cmd/controller/summary/summary.go
similarity index 98%
rename from pkg/summary/summary.go
rename to internal/cmd/controller/summary/summary.go
index fefa0b06..e799df26 100644
--- a/pkg/summary/summary.go
+++ b/internal/cmd/controller/summary/summary.go
@@ -1,4 +1,4 @@
-// Package summary provides a summary of a bundle's state. (fleetcontroller)
+// Package summary provides a summary of a bundle's state.
 package summary
 
 import (
diff --git a/pkg/target/mapping.go b/internal/cmd/controller/target/mapping.go
similarity index 100%
rename from pkg/target/mapping.go
rename to internal/cmd/controller/target/mapping.go
diff --git a/pkg/target/matcher/bundlematch.go b/internal/cmd/controller/target/matcher/bundlematch.go
similarity index 100%
rename from pkg/target/matcher/bundlematch.go
rename to internal/cmd/controller/target/matcher/bundlematch.go
diff --git a/pkg/target/matcher/clustermatcher.go b/internal/cmd/controller/target/matcher/clustermatcher.go
similarity index 100%
rename from pkg/target/matcher/clustermatcher.go
rename to internal/cmd/controller/target/matcher/clustermatcher.go
diff --git a/pkg/target/partition.go b/internal/cmd/controller/target/partition.go
similarity index 98%
rename from pkg/target/partition.go
rename to internal/cmd/controller/target/partition.go
index 8d99814a..395f4f2c 100644
--- a/pkg/target/partition.go
+++ b/internal/cmd/controller/target/partition.go
@@ -3,8 +3,8 @@ package target
 import (
 	"fmt"
 
+	"github.com/rancher/fleet/internal/cmd/controller/target/matcher"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/target/matcher"
 	"k8s.io/apimachinery/pkg/util/intstr"
 )
 
diff --git a/pkg/target/target.go b/internal/cmd/controller/target/target.go
similarity index 98%
rename from pkg/target/target.go
rename to internal/cmd/controller/target/target.go
index f23038fd..44eaedd2 100644
--- a/pkg/target/target.go
+++ b/internal/cmd/controller/target/target.go
@@ -1,4 +1,4 @@
-// Package target provides functionality around building and deploying bundledeployments. (fleetcontroller)
+// Package target provides functionality around building and deploying bundledeployments.
 //
 // Each "Target" represents a bundle, cluster pair and will be transformed into a bundledeployment.
 // The manifest, persisted in the content resource, contains the resources available to
@@ -17,12 +17,12 @@ import (
 	"github.com/sirupsen/logrus"
 	kyaml "sigs.k8s.io/yaml"
 
+	"github.com/rancher/fleet/internal/cmd/controller/options"
+	"github.com/rancher/fleet/internal/cmd/controller/summary"
+	"github.com/rancher/fleet/internal/cmd/controller/target/matcher"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/manifest"
-	"github.com/rancher/fleet/pkg/options"
-	"github.com/rancher/fleet/pkg/summary"
-	"github.com/rancher/fleet/pkg/target/matcher"
 
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
 	"github.com/rancher/wrangler/pkg/name"
diff --git a/pkg/target/target_test.go b/internal/cmd/controller/target/target_test.go
similarity index 100%
rename from pkg/target/target_test.go
rename to internal/cmd/controller/target/target_test.go
diff --git a/pkg/config/config.go b/internal/config/config.go
similarity index 100%
rename from pkg/config/config.go
rename to internal/config/config.go
diff --git a/pkg/content/helpers.go b/internal/content/helpers.go
similarity index 100%
rename from pkg/content/helpers.go
rename to internal/content/helpers.go
diff --git a/pkg/fleetyaml/fleetyaml.go b/internal/fleetyaml/fleetyaml.go
similarity index 100%
rename from pkg/fleetyaml/fleetyaml.go
rename to internal/fleetyaml/fleetyaml.go
diff --git a/pkg/fleetyaml/fleetyaml_test.go b/internal/fleetyaml/fleetyaml_test.go
similarity index 100%
rename from pkg/fleetyaml/fleetyaml_test.go
rename to internal/fleetyaml/fleetyaml_test.go
diff --git a/pkg/helmdeployer/capabilities.go b/internal/helmdeployer/capabilities.go
similarity index 100%
rename from pkg/helmdeployer/capabilities.go
rename to internal/helmdeployer/capabilities.go
diff --git a/pkg/helmdeployer/deployer.go b/internal/helmdeployer/deployer.go
similarity index 98%
rename from pkg/helmdeployer/deployer.go
rename to internal/helmdeployer/deployer.go
index 6b4b8686..d862c67c 100644
--- a/pkg/helmdeployer/deployer.go
+++ b/internal/helmdeployer/deployer.go
@@ -8,7 +8,7 @@ import (
 	"time"
 
 	"github.com/pkg/errors"
-	"github.com/rancher/fleet/pkg/config"
+	"github.com/rancher/fleet/internal/config"
 	"github.com/rancher/fleet/pkg/durations"
 	"github.com/sirupsen/logrus"
 	"helm.sh/helm/v3/pkg/action"
@@ -19,12 +19,12 @@ import (
 	"helm.sh/helm/v3/pkg/storage/driver"
 	"k8s.io/client-go/tools/cache"
 
+	"github.com/rancher/fleet/internal/helmdeployer/kustomize"
+	"github.com/rancher/fleet/internal/helmdeployer/rawyaml"
+	"github.com/rancher/fleet/internal/helmdeployer/render"
+	"github.com/rancher/fleet/internal/manifest"
+	name2 "github.com/rancher/fleet/internal/name"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/kustomize"
-	"github.com/rancher/fleet/pkg/manifest"
-	name2 "github.com/rancher/fleet/pkg/name"
-	"github.com/rancher/fleet/pkg/rawyaml"
-	"github.com/rancher/fleet/pkg/render"
 
 	"github.com/rancher/wrangler/pkg/apply"
 	corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
diff --git a/pkg/helmdeployer/deployer_test.go b/internal/helmdeployer/deployer_test.go
similarity index 100%
rename from pkg/helmdeployer/deployer_test.go
rename to internal/helmdeployer/deployer_test.go
diff --git a/pkg/helmdeployer/impersonate.go b/internal/helmdeployer/impersonate.go
similarity index 100%
rename from pkg/helmdeployer/impersonate.go
rename to internal/helmdeployer/impersonate.go
diff --git a/pkg/kustomize/kstatus.go b/internal/helmdeployer/kustomize/kstatus.go
similarity index 100%
rename from pkg/kustomize/kstatus.go
rename to internal/helmdeployer/kustomize/kstatus.go
diff --git a/pkg/kustomize/kustomize.go b/internal/helmdeployer/kustomize/kustomize.go
similarity index 96%
rename from pkg/kustomize/kustomize.go
rename to internal/helmdeployer/kustomize/kustomize.go
index 75277401..4c1bc630 100644
--- a/pkg/kustomize/kustomize.go
+++ b/internal/helmdeployer/kustomize/kustomize.go
@@ -3,8 +3,8 @@ package kustomize
 import (
 	"path/filepath"
 
-	"github.com/rancher/fleet/pkg/content"
-	"github.com/rancher/fleet/pkg/manifest"
+	"github.com/rancher/fleet/internal/content"
+	"github.com/rancher/fleet/internal/manifest"
 
 	"github.com/rancher/wrangler/pkg/data/convert"
 	"github.com/rancher/wrangler/pkg/slice"
diff --git a/pkg/rawyaml/resources.go b/internal/helmdeployer/rawyaml/resources.go
similarity index 100%
rename from pkg/rawyaml/resources.go
rename to internal/helmdeployer/rawyaml/resources.go
diff --git a/pkg/render/helm.go b/internal/helmdeployer/render/helm.go
similarity index 93%
rename from pkg/render/helm.go
rename to internal/helmdeployer/render/helm.go
index 2c05e87c..aa98abf9 100644
--- a/pkg/render/helm.go
+++ b/internal/helmdeployer/render/helm.go
@@ -7,12 +7,12 @@ import (
 
 	"helm.sh/helm/v3/pkg/chart"
 
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/fleetyaml"
+	"github.com/rancher/fleet/internal/helmdeployer/rawyaml"
+	"github.com/rancher/fleet/internal/helmdeployer/render/patch"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/bundlereader"
-	"github.com/rancher/fleet/pkg/fleetyaml"
-	"github.com/rancher/fleet/pkg/manifest"
-	"github.com/rancher/fleet/pkg/patch"
-	"github.com/rancher/fleet/pkg/rawyaml"
 
 	"github.com/rancher/wrangler/pkg/kv"
 
diff --git a/pkg/patch/patch.go b/internal/helmdeployer/render/patch/patch.go
similarity index 97%
rename from pkg/patch/patch.go
rename to internal/helmdeployer/render/patch/patch.go
index 3701ab75..91429aef 100644
--- a/pkg/patch/patch.go
+++ b/internal/helmdeployer/render/patch/patch.go
@@ -9,9 +9,9 @@ import (
 
 	"github.com/pkg/errors"
 
+	"github.com/rancher/fleet/internal/content"
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/content"
-	"github.com/rancher/fleet/pkg/manifest"
 
 	"github.com/rancher/wrangler/pkg/patch"
 
diff --git a/pkg/helmdeployer/template.go b/internal/helmdeployer/template.go
similarity index 95%
rename from pkg/helmdeployer/template.go
rename to internal/helmdeployer/template.go
index 082977be..82cc2b91 100644
--- a/pkg/helmdeployer/template.go
+++ b/internal/helmdeployer/template.go
@@ -3,8 +3,8 @@ package helmdeployer
 import (
 	"io"
 
+	"github.com/rancher/fleet/internal/manifest"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/manifest"
 
 	"github.com/sirupsen/logrus"
 
diff --git a/pkg/manifest/decode.go b/internal/manifest/decode.go
similarity index 100%
rename from pkg/manifest/decode.go
rename to internal/manifest/decode.go
diff --git a/pkg/manifest/lookup.go b/internal/manifest/lookup.go
similarity index 93%
rename from pkg/manifest/lookup.go
rename to internal/manifest/lookup.go
index 75881deb..1884ec1b 100644
--- a/pkg/manifest/lookup.go
+++ b/internal/manifest/lookup.go
@@ -1,7 +1,7 @@
 package manifest
 
 import (
-	"github.com/rancher/fleet/pkg/content"
+	"github.com/rancher/fleet/internal/content"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
diff --git a/pkg/manifest/manifest.go b/internal/manifest/manifest.go
similarity index 100%
rename from pkg/manifest/manifest.go
rename to internal/manifest/manifest.go
diff --git a/pkg/manifest/output.go b/internal/manifest/output.go
similarity index 94%
rename from pkg/manifest/output.go
rename to internal/manifest/output.go
index 9648be20..26dcac44 100644
--- a/pkg/manifest/output.go
+++ b/internal/manifest/output.go
@@ -7,7 +7,7 @@ import (
 	"io"
 	"time"
 
-	"github.com/rancher/fleet/pkg/content"
+	"github.com/rancher/fleet/internal/content"
 )
 
 func (m *Manifest) ToTarGZ() (io.Reader, error) {
diff --git a/pkg/manifest/store.go b/internal/manifest/store.go
similarity index 96%
rename from pkg/manifest/store.go
rename to internal/manifest/store.go
index 7a5e9ac5..06450b99 100644
--- a/pkg/manifest/store.go
+++ b/internal/manifest/store.go
@@ -3,7 +3,7 @@ package manifest
 import (
 	"sync"
 
-	"github.com/rancher/fleet/pkg/content"
+	"github.com/rancher/fleet/internal/content"
 
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
diff --git a/pkg/name/suite_test.go b/internal/name/suite_test.go
similarity index 100%
rename from pkg/name/suite_test.go
rename to internal/name/suite_test.go
diff --git a/pkg/registration/secret.go b/internal/registration/secret.go
similarity index 100%
rename from pkg/registration/secret.go
rename to internal/registration/secret.go
diff --git a/scripts/agent-dev b/scripts/agent-dev
index c64922fb..28a8d701 100755
--- a/scripts/agent-dev
+++ b/scripts/agent-dev
@@ -15,20 +15,13 @@ LINKFLAGS="$LINKFLAGS -extldflags -static"
 
 AGENT_ARCH=amd64
 
-function build-binary() {
-    local BINARY=$1-linux-$AGENT_ARCH
-    local OUT="bin/$BINARY"
-    if [ "$1" = "fleetagent" ]; then
-        OUT="$OUT ./cmd/$1"
-    fi
-
-    echo "Building binary: $BINARY"
-    GOOS=linux GOARCH=$AGENT_ARCH CGO_ENABLED=0 go build -ldflags "$LINKFLAGS" -o $OUT
-    cp bin/$BINARY dist/artifacts/
-}
-
-build-binary fleet
-build-binary fleetagent
+echo "Building binary: fleet"
+GOOS=linux GOARCH=$AGENT_ARCH CGO_ENABLED=0 go build -ldflags "$LINKFLAGS" -o bin/fleet-linux-$AGENT_ARCH ./cmd/fleetcli
+cp bin/fleet-linux-$AGENT_ARCH dist/artifacts/
+
+echo "Building binary: fleetagent"
+GOOS=linux GOARCH=$AGENT_ARCH CGO_ENABLED=0 go build -ldflags "$LINKFLAGS" -o bin/fleetagent-linux-$AGENT_ARCH ./cmd/fleetagent
+cp bin/fleetagent-linux-$AGENT_ARCH dist/artifacts/
 
 IMAGE=$REPO/fleet-agent:$TAG
 echo "Building fleet-agent image for linux-$AGENT_ARCH: $IMAGE"
diff --git a/scripts/build b/scripts/build
index 97a56291..f0860988 100755
--- a/scripts/build
+++ b/scripts/build
@@ -28,7 +28,7 @@ function build-binaries() {
     if [ $1 = "windows" ]; then
         TEMP_SUFFIX=".exe"
     fi
-    GOOS=${1} GOARCH=${2} CGO_ENABLED=0 go build -gcflags="all=${GCFLAGS}" -ldflags "$TEMP_LINKFLAGS" -o bin/fleet-${1}-${2}${TEMP_SUFFIX}
+    GOOS=${1} GOARCH=${2} CGO_ENABLED=0 go build -gcflags="all=${GCFLAGS}" -ldflags "$TEMP_LINKFLAGS" -o bin/fleet-${1}-${2}${TEMP_SUFFIX} ./cmd/fleetcli
     if ! [ $1 = "darwin" ]; then
         GOOS=${1} GOARCH=${2} CGO_ENABLED=0 go build -gcflags="all=${GCFLAGS}" -ldflags "$TEMP_LINKFLAGS" -o bin/fleetcontroller-${1}-${2}${TEMP_SUFFIX} ./cmd/fleetcontroller
         GOOS=${1} GOARCH=${2} CGO_ENABLED=0 go build -gcflags="all=${GCFLAGS}" -ldflags "$TEMP_LINKFLAGS" -o bin/fleetagent-${1}-${2}${TEMP_SUFFIX} ./cmd/fleetagent
diff --git a/scripts/package-helm b/scripts/package-helm
index d397b90c..2e480885 100755
--- a/scripts/package-helm
+++ b/scripts/package-helm
@@ -36,7 +36,7 @@ sed -i \
     -e 's/tag: dev/tag: '${HELM_TAG}'/' \
     build/charts/fleet-agent/values.yaml
 
-go run ./pkg/codegen crds ./build/charts/fleet-crd/templates/crds.yaml
+go run ./cmd/codegen crds ./build/charts/fleet-crd/templates/crds.yaml
 helm package -d ./dist/artifacts ./build/charts/fleet
 helm package -d ./dist/artifacts ./build/charts/fleet-crd
 helm package -d ./dist/artifacts ./build/charts/fleet-agent


Test patch:
diff --git a/.github/workflows/e2e-ci.yml b/.github/workflows/e2e-ci.yml
index ddf093af..34a4eb61 100644
--- a/.github/workflows/e2e-ci.yml
+++ b/.github/workflows/e2e-ci.yml
@@ -55,7 +55,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Build Docker Images
diff --git a/.github/workflows/e2e-multicluster-ci.yml b/.github/workflows/e2e-multicluster-ci.yml
index 3b9ae8f2..6eeac2b3 100644
--- a/.github/workflows/e2e-multicluster-ci.yml
+++ b/.github/workflows/e2e-multicluster-ci.yml
@@ -51,7 +51,7 @@ jobs:
         run: |
           go build -o bin/fleetcontroller-linux-$GOARCH ./cmd/fleetcontroller
 
-          go build -o "bin/fleet-linux-$GOARCH"
+          go build -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli
           go build -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent
       -
         name: Build Docker Images
diff --git a/integrationtests/agent/suite_test.go b/integrationtests/agent/suite_test.go
index b093623b..5ab668c0 100644
--- a/integrationtests/agent/suite_test.go
+++ b/integrationtests/agent/suite_test.go
@@ -10,15 +10,15 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/rancher/fleet/integrationtests/utils"
-	"github.com/rancher/fleet/modules/agent/pkg/controllers/bundledeployment"
-	"github.com/rancher/fleet/modules/agent/pkg/deployer"
-	"github.com/rancher/fleet/modules/agent/pkg/trigger"
+	"github.com/rancher/fleet/internal/cmd/agent/controllers/bundledeployment"
+	"github.com/rancher/fleet/internal/cmd/agent/deployer"
+	"github.com/rancher/fleet/internal/cmd/agent/trigger"
+	"github.com/rancher/fleet/internal/helmdeployer"
+	"github.com/rancher/fleet/internal/manifest"
 	"github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 	"github.com/rancher/fleet/pkg/durations"
 	"github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
 	fleetgen "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
-	"github.com/rancher/fleet/pkg/helmdeployer"
-	"github.com/rancher/fleet/pkg/manifest"
 	"github.com/rancher/lasso/pkg/cache"
 	lassoclient "github.com/rancher/lasso/pkg/client"
 	"github.com/rancher/lasso/pkg/controller"
diff --git a/integrationtests/cli/apply/apply_test.go b/integrationtests/cli/apply/apply_test.go
index 9011122c..b4128248 100644
--- a/integrationtests/cli/apply/apply_test.go
+++ b/integrationtests/cli/apply/apply_test.go
@@ -5,7 +5,7 @@ import (
 	. "github.com/onsi/gomega"
 	"github.com/onsi/gomega/gbytes"
 	"github.com/rancher/fleet/integrationtests/cli"
-	"github.com/rancher/fleet/modules/cli/apply"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 )
 
 var _ = Describe("Fleet apply", Ordered, func() {
diff --git a/integrationtests/cli/apply/suite_test.go b/integrationtests/cli/apply/suite_test.go
index b02077eb..5c2d2c8d 100644
--- a/integrationtests/cli/apply/suite_test.go
+++ b/integrationtests/cli/apply/suite_test.go
@@ -4,8 +4,8 @@ import (
 	"context"
 	"testing"
 
-	"github.com/rancher/fleet/modules/cli/apply"
-	"github.com/rancher/fleet/modules/cli/pkg/client"
+	"github.com/rancher/fleet/internal/client"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
diff --git a/integrationtests/cli/apply/target_test.go b/integrationtests/cli/apply/target_test.go
index c75580b3..2d780e2b 100644
--- a/integrationtests/cli/apply/target_test.go
+++ b/integrationtests/cli/apply/target_test.go
@@ -5,7 +5,7 @@ import (
 	"os"
 
 	"github.com/rancher/fleet/integrationtests/cli"
-	"github.com/rancher/fleet/modules/cli/apply"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 
 	. "github.com/onsi/ginkgo/v2"
diff --git a/integrationtests/cli/helm/helm_test.go b/integrationtests/cli/helm/helm_test.go
index 36d09c73..16ab0e18 100644
--- a/integrationtests/cli/helm/helm_test.go
+++ b/integrationtests/cli/helm/helm_test.go
@@ -7,8 +7,8 @@ import (
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
 	"github.com/rancher/fleet/integrationtests/cli"
-	"github.com/rancher/fleet/modules/cli/apply"
-	"github.com/rancher/fleet/pkg/bundlereader"
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 )
 
 const (
diff --git a/integrationtests/cli/helm/suite_test.go b/integrationtests/cli/helm/suite_test.go
index 0a5f8854..785779ff 100644
--- a/integrationtests/cli/helm/suite_test.go
+++ b/integrationtests/cli/helm/suite_test.go
@@ -4,8 +4,8 @@ import (
 	"context"
 	"testing"
 
-	"github.com/rancher/fleet/modules/cli/apply"
-	"github.com/rancher/fleet/modules/cli/pkg/client"
+	"github.com/rancher/fleet/internal/client"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
diff --git a/integrationtests/controller/bundle/suite_test.go b/integrationtests/controller/bundle/suite_test.go
index 12fc7db5..8927eaec 100644
--- a/integrationtests/controller/bundle/suite_test.go
+++ b/integrationtests/controller/bundle/suite_test.go
@@ -8,16 +8,16 @@ import (
 	"time"
 
 	"github.com/rancher/fleet/integrationtests/utils"
-	"github.com/rancher/fleet/pkg/controllers/bundle"
-	"github.com/rancher/fleet/pkg/target"
+	"github.com/rancher/fleet/internal/cmd/controller/controllers/bundle"
+	"github.com/rancher/fleet/internal/cmd/controller/target"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
+	"github.com/rancher/fleet/internal/manifest"
 	"github.com/rancher/fleet/pkg/durations"
 	"github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
-	"github.com/rancher/fleet/pkg/manifest"
 	"github.com/rancher/lasso/pkg/cache"
 	lassoclient "github.com/rancher/lasso/pkg/client"
 	"github.com/rancher/lasso/pkg/controller"
diff --git a/modules/cli/cmds/apply_test.go b/internal/cmd/cli/apply_test.go
similarity index 96%
rename from modules/cli/cmds/apply_test.go
rename to internal/cmd/cli/apply_test.go
index 739cd0ac..eaecb91e 100644
--- a/modules/cli/cmds/apply_test.go
+++ b/internal/cmd/cli/apply_test.go
@@ -1,4 +1,4 @@
-package cmds
+package cli
 
 import (
 	"errors"
@@ -7,8 +7,8 @@ import (
 	"github.com/google/go-cmp/cmp"
 	"sigs.k8s.io/yaml"
 
-	"github.com/rancher/fleet/modules/cli/apply"
-	"github.com/rancher/fleet/pkg/bundlereader"
+	"github.com/rancher/fleet/internal/bundlereader"
+	"github.com/rancher/fleet/internal/cmd/cli/apply"
 )
 
 const (
diff --git a/modules/cli/cmds/test.go b/internal/cmd/cli/test.go
similarity index 96%
rename from modules/cli/cmds/test.go
rename to internal/cmd/cli/test.go
index 2f8cd39f..06fa7a65 100644
--- a/modules/cli/cmds/test.go
+++ b/internal/cmd/cli/test.go
@@ -1,11 +1,11 @@
-package cmds
+package cli
 
 import (
 	"os"
 
 	"github.com/spf13/cobra"
 
-	"github.com/rancher/fleet/modules/cli/match"
+	"github.com/rancher/fleet/internal/cmd/cli/match"
 	command "github.com/rancher/wrangler-cli"
 )
 
diff --git a/pkg/controllers/manageagent/manageagent_test.go b/internal/cmd/controller/controllers/manageagent/manageagent_test.go
similarity index 99%
rename from pkg/controllers/manageagent/manageagent_test.go
rename to internal/cmd/controller/controllers/manageagent/manageagent_test.go
index 822d0419..fb1c2934 100644
--- a/pkg/controllers/manageagent/manageagent_test.go
+++ b/internal/cmd/controller/controllers/manageagent/manageagent_test.go
@@ -6,7 +6,7 @@ import (
 	"testing"
 
 	"github.com/golang/mock/gomock"
-	"github.com/rancher/fleet/internal/mocks"
+	"github.com/rancher/fleet/internal/cmd/controller/mocks"
 
 	fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
 
diff --git a/pkg/name/name.go b/internal/name/name.go
similarity index 100%
rename from pkg/name/name.go
rename to internal/name/name.go
diff --git a/pkg/name/name_test.go b/internal/name/name_test.go
similarity index 97%
rename from pkg/name/name_test.go
rename to internal/name/name_test.go
index a0a77084..ad02ab8d 100644
--- a/pkg/name/name_test.go
+++ b/internal/name/name_test.go
@@ -3,7 +3,7 @@ package name_test
 import (
 	"fmt"
 
-	"github.com/rancher/fleet/pkg/name"
+	"github.com/rancher/fleet/internal/name"
 
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"