-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
292bc81
commit d30e88b
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ascp | ||
|
||
import ( | ||
"github.com/awslabs/eksdemo/pkg/application" | ||
"github.com/awslabs/eksdemo/pkg/cmd" | ||
"github.com/awslabs/eksdemo/pkg/installer" | ||
"github.com/awslabs/eksdemo/pkg/resource" | ||
"github.com/awslabs/eksdemo/pkg/resource/irsa" | ||
"github.com/awslabs/eksdemo/pkg/template" | ||
) | ||
|
||
// | ||
|
||
func NewApp() *application.Application { | ||
return &application.Application{ | ||
Command: cmd.Command{ | ||
Parent: "example", | ||
Name: "ascp", | ||
Description: "Example for AWS Secrets Manager and Config Provider for Secret Store CSI Driver", | ||
}, | ||
|
||
Dependencies: []*resource.Resource{ | ||
irsa.NewResourceWithOptions(&irsa.IrsaOptions{ | ||
CommonOptions: resource.CommonOptions{ | ||
Name: "example-ascp-irsa", | ||
}, | ||
PolicyType: irsa.PolicyDocument, | ||
PolicyDocTemplate: &template.TextTemplate{ | ||
Template: policyDocument, | ||
}, | ||
}), | ||
}, | ||
|
||
Installer: &installer.ManifestInstaller{ | ||
AppName: "example-ascp", | ||
ResourceTemplate: &template.TextTemplate{ | ||
Template: secretsProviderClassTemplate + serviceAccountTemplate + serviceAndDeploymentTemplate, | ||
}, | ||
}, | ||
|
||
Options: &application.ApplicationOptions{ | ||
DisableServiceAccountFlag: true, | ||
DisableVersionFlag: true, | ||
Namespace: "ascp", | ||
ServiceAccount: "nginx-deployment-sa", | ||
}, | ||
} | ||
} | ||
|
||
// https://github.com/aws/secrets-store-csi-driver-provider-aws#usage | ||
const policyDocument = ` | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Action: | ||
- secretsmanager:GetSecretValue | ||
- secretsmanager:DescribeSecret | ||
Resource: arn:{{ .Partition }}:secretsmanager:{{ .Region }}:{{ .Account }}:secret:MySecret-?????? | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package ascp | ||
|
||
// https://github.com/aws/secrets-store-csi-driver-provider-aws/blob/main/examples/ExampleDeployment.yaml | ||
const secretsProviderClassTemplate = `--- | ||
apiVersion: secrets-store.csi.x-k8s.io/v1 | ||
kind: SecretProviderClass | ||
metadata: | ||
name: nginx-deployment-aws-secrets | ||
spec: | ||
provider: aws | ||
parameters: | ||
objects: | | ||
- objectName: "MySecret" | ||
objectType: "secretsmanager" | ||
` | ||
|
||
const serviceAccountTemplate = `--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
annotations: | ||
{{ .IrsaAnnotation }} | ||
name: {{ .ServiceAccount}} | ||
namespace: {{ .Namespace }} | ||
` | ||
|
||
// https://github.com/aws/secrets-store-csi-driver-provider-aws/blob/main/examples/ExampleDeployment.yaml | ||
const serviceAndDeploymentTemplate = `--- | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-deployment | ||
namespace: {{ .Namespace }} | ||
labels: | ||
app: nginx | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
namespace: {{ .Namespace }} | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
serviceAccountName: nginx-deployment-sa | ||
volumes: | ||
- name: secrets-store-inline | ||
csi: | ||
driver: secrets-store.csi.k8s.io | ||
readOnly: true | ||
volumeAttributes: | ||
secretProviderClass: "nginx-deployment-aws-secrets" | ||
containers: | ||
- name: nginx-deployment | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: secrets-store-inline | ||
mountPath: "/mnt/secrets-store" | ||
readOnly: true | ||
` |