Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add DeploymentTemplate controller for GitOps support #8001

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
af3498c
working
willdavsmith Oct 4, 2024
c3534bf
deletion works
willdavsmith Oct 4, 2024
af0d1bc
who watches the watcher
willdavsmith Oct 10, 2024
d94f505
controller-gen update
willdavsmith Oct 10, 2024
5a47396
PR
willdavsmith Oct 17, 2024
2b3e3ba
it works
willdavsmith Oct 24, 2024
5a60fb9
fixing bugs
willdavsmith Oct 25, 2024
df3eb33
reconcile app
willdavsmith Oct 28, 2024
643d38a
gkm tests
willdavsmith Oct 29, 2024
964f7d6
PR
willdavsmith Oct 29, 2024
2b31fb7
removing fluxcontroller
willdavsmith Oct 29, 2024
59ec01d
FTs
willdavsmith Nov 1, 2024
22a28e0
FTs
willdavsmith Nov 1, 2024
066c38c
FTs
willdavsmith Nov 1, 2024
d46d479
PR
willdavsmith Nov 1, 2024
97676aa
fix
willdavsmith Nov 4, 2024
b0a8966
resource group
willdavsmith Nov 4, 2024
3af3941
CLI
willdavsmith Nov 6, 2024
5d52e69
Suggestions for users
willdavsmith Nov 14, 2024
b676311
gkm unit tests
willdavsmith Nov 21, 2024
0d46bd4
Updating functional tests
willdavsmith Nov 21, 2024
66927ee
PR
willdavsmith Nov 21, 2024
db96f40
PR
willdavsmith Nov 21, 2024
b57d9c4
PR
willdavsmith Nov 21, 2024
17a501f
PR
willdavsmith Nov 21, 2024
a85eb27
PR
willdavsmith Nov 21, 2024
ffc83af
PR
willdavsmith Nov 21, 2024
be204ce
PR
willdavsmith Nov 21, 2024
0ddd6c0
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Nov 21, 2024
bb34c56
fix tests
willdavsmith Nov 22, 2024
794ee14
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Dec 5, 2024
d814bcd
deps
willdavsmith Dec 5, 2024
df2a9d0
Fixing tests
willdavsmith Dec 6, 2024
8fdfc6c
Fixing tests
willdavsmith Dec 6, 2024
ebe165e
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Dec 6, 2024
d6a6c42
PR
willdavsmith Dec 23, 2024
ab44f4f
PR
willdavsmith Dec 23, 2024
34aef5a
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Dec 23, 2024
be0a636
PR
willdavsmith Dec 23, 2024
f7ef451
PR
willdavsmith Dec 23, 2024
e47c1f0
PR
willdavsmith Dec 24, 2024
e8c861a
submodule
willdavsmith Dec 24, 2024
0b80d92
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Dec 24, 2024
4ed836d
PR
willdavsmith Dec 24, 2024
ab65f7f
Fixing tests
willdavsmith Dec 24, 2024
0f9fd39
PR
willdavsmith Dec 24, 2024
a17b4bb
namespacing
willdavsmith Dec 26, 2024
d7bb509
fmt
willdavsmith Dec 26, 2024
6b3ccfc
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Dec 26, 2024
667b682
fix test
willdavsmith Dec 27, 2024
483e210
fix test
willdavsmith Dec 27, 2024
76c6e0b
Using hash in deploymenttemplate.status
willdavsmith Jan 10, 2025
92088d1
Merge branch 'main' into deploymenttemplatecontroller
willdavsmith Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/rad/cmd/bicep.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

var bicepCmd = &cobra.Command{
Use: "bicep",
Short: "Manage bicep compiler",
Long: `Manage bicep compiler used by Radius`,
Short: "Handle bicep-specific tasks for Radius",
Long: `Handle bicep-specific tasks for Radius`,
}

func init() {
Expand Down
4 changes: 4 additions & 0 deletions cmd/rad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
app_list "github.com/radius-project/radius/pkg/cli/cmd/app/list"
app_show "github.com/radius-project/radius/pkg/cli/cmd/app/show"
app_status "github.com/radius-project/radius/pkg/cli/cmd/app/status"
bicep_generate_kubernetes_manifest "github.com/radius-project/radius/pkg/cli/cmd/bicep/generatekubernetesmanifest"
bicep_publish "github.com/radius-project/radius/pkg/cli/cmd/bicep/publish"
bicep_publishextension "github.com/radius-project/radius/pkg/cli/cmd/bicep/publishextension"
credential "github.com/radius-project/radius/pkg/cli/cmd/credential"
Expand Down Expand Up @@ -349,6 +350,9 @@ func initSubCommands() {
bicepPublishCmd, _ := bicep_publish.NewCommand(framework)
bicepCmd.AddCommand(bicepPublishCmd)

bicepGenerateKubernetesManifestCmd, _ := bicep_generate_kubernetes_manifest.NewCommand(framework)
bicepCmd.AddCommand(bicepGenerateKubernetesManifestCmd)

bicepPublishExtensionCmd, _ := bicep_publishextension.NewCommand(framework)
bicepCmd.AddCommand(bicepPublishExtensionCmd)

Expand Down
93 changes: 93 additions & 0 deletions deploy/Chart/crds/radius/radapp.io_deploymentresources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.0
name: deploymentresources.radapp.io
spec:
group: radapp.io
names:
categories:
- all
- radius
kind: DeploymentResource
listKind: DeploymentResourceList
plural: deploymentresources
singular: deploymentresource
scope: Namespaced
versions:
- name: v1alpha3
schema:
openAPIV3Schema:
description: DeploymentResource is the Schema for the DeploymentResources
API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: DeploymentResourceSpec defines the desired state of DeploymentResource
properties:
id:
description: Id is the resource Id.
type: string
providerConfig:
description: ProviderConfig specifies the scope for resources
type: string
type: object
status:
description: DeploymentResourceStatus defines the observed state of DeploymentResource
properties:
id:
description: Id is the resource Id.
type: string
message:
description: Message is a human-readable description of the status
of the Deployment Resource.
type: string
observedGeneration:
description: ObservedGeneration is the most recent generation observed
for this DeploymentResource.
format: int64
type: integer
operation:
description: Operation tracks the status of an in-progress provisioning
operation.
properties:
operationKind:
description: OperationKind describes the type of operation being
performed.
type: string
resumeToken:
description: ResumeToken is a token that can be used to resume
an in-progress provisioning operation.
type: string
type: object
phrase:
description: Phrase indicates the current status of the Deployment
Resource.
type: string
providerConfig:
description: ProviderConfig specifies the scope for resources
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
105 changes: 105 additions & 0 deletions deploy/Chart/crds/radius/radapp.io_deploymenttemplates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.0
name: deploymenttemplates.radapp.io
spec:
group: radapp.io
names:
categories:
- all
- radius
kind: DeploymentTemplate
listKind: DeploymentTemplateList
plural: deploymenttemplates
singular: deploymenttemplate
scope: Namespaced
versions:
- name: v1alpha3
schema:
openAPIV3Schema:
description: DeploymentTemplate is the Schema for the deploymenttemplates
API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: DeploymentTemplateSpec defines the desired state of DeploymentTemplate
properties:
parameters:
additionalProperties:
type: string
description: Parameters is the ARM JSON parameters for the template.
type: object
providerConfig:
description: ProviderConfig specifies the scope for resources
type: string
template:
description: Template is the ARM JSON manifest that defines the resources
to deploy.
type: string
type: object
status:
description: DeploymentTemplateStatus defines the observed state of DeploymentTemplate
properties:
message:
description: Message is a human-readable description of the status
of the Deployment Template.
type: string
observedGeneration:
description: ObservedGeneration is the most recent generation observed
for this DeploymentTemplate.
format: int64
type: integer
operation:
description: Operation tracks the status of an in-progress provisioning
operation.
properties:
operationKind:
description: OperationKind describes the type of operation being
performed.
type: string
resumeToken:
description: ResumeToken is a token that can be used to resume
an in-progress provisioning operation.
type: string
type: object
outputResources:
description: OutputResources is a list of the resourceIDs that were
created by the template on the last deployment.
items:
type: string
type: array
phrase:
description: Phrase indicates the current status of the Deployment
Template.
type: string
resource:
description: Resource is the resource id of the deployment.
type: string
statusHash:
description: StatusHash is a hash of the DeploymentTemplate's status.
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
4 changes: 4 additions & 0 deletions deploy/Chart/templates/controller/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ rules:
resources:
- recipes
- recipes/status
- deploymenttemplates
- deploymenttemplates/status
- deploymentresources
- deploymentresources/status
verbs:
- create
- delete
Expand Down
18 changes: 4 additions & 14 deletions pkg/cli/bicep/deployment_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,22 @@ package bicep
import (
"encoding/json"
"fmt"
"io/fs"
"os"
"strings"

"github.com/radius-project/radius/pkg/cli/clients"
"github.com/radius-project/radius/pkg/cli/filesystem"
)

// ParameterParser is used to parse the parameters as part of the `rad deploy` command. See the docs for `rad deploy` for examples
// of what we need to support here.
type ParameterParser struct {
FileSystem fs.FS
}

type OSFileSystem struct {
FileSystem filesystem.FileSystem
}

type ParameterFile struct {
Parameters clients.DeploymentParameters `json:"parameters"`
}

// The Open function opens the file specified by the name parameter and returns a file object and an error if the file
// cannot be opened.
func (OSFileSystem) Open(name string) (fs.File, error) {
return os.Open(name)
}

// ParseFileContents takes in a map of strings and any type and returns a DeploymentParameters object and
// an error if one occurs during the process.
func (pp ParameterParser) ParseFileContents(input map[string]any) (clients.DeploymentParameters, error) {
Expand Down Expand Up @@ -90,7 +80,7 @@ func (pp ParameterParser) parseSingle(input string, output clients.DeploymentPar
if strings.HasPrefix(input, "@") {
// input is a file that declares multiple parameters
filePath := strings.TrimPrefix(input, "@")
b, err := fs.ReadFile(pp.FileSystem, filePath)
b, err := pp.FileSystem.ReadFile(filePath)
if err != nil {
return err
}
Expand All @@ -111,7 +101,7 @@ func (pp ParameterParser) parseSingle(input string, output clients.DeploymentPar
if strings.HasPrefix(parameterValue, "@") {
// input is a file that declares a single parameter
filePath := strings.TrimPrefix(parameterValue, "@")
b, err := fs.ReadFile(pp.FileSystem, filePath)
b, err := pp.FileSystem.ReadFile(filePath)
if err != nil {
return err
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/cli/bicep/deployment_parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing/fstest"

"github.com/radius-project/radius/pkg/cli/clients"
"github.com/radius-project/radius/pkg/cli/filesystem"
"github.com/stretchr/testify/require"
)

Expand All @@ -36,7 +37,7 @@ func Test_Parameters_Invalid(t *testing.T) {
}

parser := ParameterParser{
FileSystem: fstest.MapFS{},
FileSystem: filesystem.NewMemMapFileSystem(),
}

for _, input := range inputs {
Expand All @@ -56,13 +57,16 @@ func Test_ParseParameters_Overwrite(t *testing.T) {
"key3=value3",
}

// Initialize the ParameterParser with the in-memory filesystem
parser := ParameterParser{
FileSystem: fstest.MapFS{
"many.json": {
Data: []byte(`{ "parameters": { "key1": { "value": { "someValue": true } }, "key2": { "value": "overridden-value" } } }`),
},
"single.json": {
Data: []byte(`{ "someValue": "another-value" }`),
FileSystem: filesystem.MemMapFileSystem{
InternalFileSystem: fstest.MapFS{
"many.json": {
Data: []byte(`{ "parameters": { "key1": { "value": { "someValue": true } }, "key2": { "value": "overridden-value" } } }`),
},
"single.json": {
Data: []byte(`{ "someValue": "another-value" }`),
},
},
},
}
Expand Down Expand Up @@ -91,7 +95,7 @@ func Test_ParseParameters_Overwrite(t *testing.T) {

func Test_ParseParameters_File(t *testing.T) {
parser := ParameterParser{
FileSystem: fstest.MapFS{},
FileSystem: filesystem.NewMemMapFileSystem(),
}

input, err := os.ReadFile(filepath.Join("testdata", "test-parameters.json"))
Expand Down
Loading
Loading