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

Kubernetes typeDefs Revision alpha1 (WIP) #1582

Closed
Closed
Changes from all commits
Commits
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
160 changes: 99 additions & 61 deletions services/api/src/typeDefs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const gql = require('./util/gql');

// TODO: Split up this file
Expand Down Expand Up @@ -102,6 +100,7 @@ const typeDefs = gql`
ZAR
}


type File {
id: Int
filename: String
Expand Down Expand Up @@ -163,16 +162,47 @@ const typeDefs = gql`
billingSoftware: String
}

type Openshift {
# Alpha - Kubernetes may have different fields - Just for discussion
type Kubernetes {
id: Int
name: String
consoleUrl: String
name: String # Must be unique
# type: ClusterType
environments: [Environment] #namespaces
api: String
token: String
routerPattern: String
projectUser: String
sshHost: String
sshPort: String
autoGeneratedIngressPattern: String
remoteShellHost: String
remoteShellPort: String
created: String

#NOTES: We need to teach people to use kubernetes even though it's an openshift

# Can we derive these based on the Cluster Type, branch, name?

customSettings: JSON

# """
# Which internal Lagoon System is responsible for deploying
# 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy'
# """

# # TODO - TURN TO ENUMS - convert to a single field
# activeSystemsDeploy: String
# """
# Which internal Lagoon System is responsible for promoting
# 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy'
# """
# activeSystemsPromote: String
# """
# Which internal Lagoon System is responsible for promoting
# 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy'
# """
# activeSystemsRemove: String
# """
# Which internal Lagoon System is responsible for tasks
# 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy'
# """
# activeSystemsTask: String
}

type NotificationMicrosoftTeams {
Expand Down Expand Up @@ -209,6 +239,14 @@ const typeDefs = gql`

union Notification = NotificationRocketChat | NotificationSlack | NotificationMicrosoftTeams | NotificationEmail


type KubernetesEnvironmentMap {
environmentType: EnvironmentType
kubernetes: Kubernetes
}

# Someday... would like to suppor one project deploy in multiple places (clusters)

"""
Lagoon Project (like a git repository)
"""
Expand Down Expand Up @@ -250,26 +288,6 @@ const typeDefs = gql`
"""
notifications(type: NotificationType): [Notification]
"""
Which internal Lagoon System is responsible for deploying
Currently only 'lagoon_openshiftBuildDeploy' exists
"""
activeSystemsDeploy: String
"""
Which internal Lagoon System is responsible for promoting
Currently only 'lagoon_openshiftBuildDeploy' exists
"""
activeSystemsPromote: String
"""
Which internal Lagoon System is responsible for promoting
Currently only 'lagoon_openshiftRemove' exists
"""
activeSystemsRemove: String
"""
Which internal Lagoon System is responsible for tasks
Currently only 'lagoon_openshiftJob' exists
"""
activeSystemsTask: String
"""
Which branches should be deployed, can be one of:
- \`true\` - all branches are deployed
- \`false\` - no branches are deployed
Expand All @@ -296,14 +314,16 @@ const typeDefs = gql`
Should storage for this environment be calculated (\`1\` or \`0\`)
"""
storageCalc: Int

"""
Reference to OpenShift Object this Project should be deployed to
Environment > Cluster
"""
openshift: Openshift
kubernetesMap: [KubernetesMap]

"""
Pattern of OpenShift Project/Namespace that should be generated, default: \`$\{project}-$\{environmentname}\`
Kubernetes Namespace pattern that should be generated, default: \`$\{project}-$\{environmentname}\`
"""
openshiftProjectPattern: String
kubernetesNamespacePattern: String
"""
How many environments can be deployed at one timeout
"""
Expand All @@ -330,7 +350,7 @@ const typeDefs = gql`
"""
envVariables: [EnvKeyValue]
"""
Which groups are directly linked to project
Groups linked to a project
"""
groups: [GroupInterface]
}
Expand All @@ -344,14 +364,22 @@ const typeDefs = gql`
"""
id: Int
"""
Name of this Environment
Name of this Environment (not unique)
"""
name: String
"""
Unique Name (auto generated) environmentName.projectName.kubernetesName (ex. pr-104.drupal-example.ch1.amazee.io)
"""
uniqueName: String
"""
Reference to the Project Object
"""
project: Project
"""
Reference to the Kubernetes Object
"""
kubernetes: Kubernetes
"""
Which Deployment Type this environment is, can be \`branch\`, \`pullrequest\`, \`promote\`
"""
deployType: String
Expand All @@ -374,9 +402,13 @@ const typeDefs = gql`
"""
Which Environment Type this environment is, can be \`production\`, \`development\`
"""
environmentType: String
environmentType: EnvironmentType
"""
Kubernetes Namespace
"""
kubernetesNamespace: String
"""
Name of the OpenShift Project/Namespace this environment is deployed into
(DEPRECATED as of 2.0) Name of the OpenShift Project/Namespace this environment is deployed into
"""
openshiftProjectName: String
"""
Expand Down Expand Up @@ -502,7 +534,9 @@ const typeDefs = gql`
input DeleteEnvironmentInput {
name: String!
project: String!
execute: Boolean
execute: Boolean # TODO: change to two separate mutations
# Anywhere you can delete anything, change the execute thing
# Internal - deleteEnvironmentFromOpenshift
}

type Query {
Expand All @@ -515,23 +549,27 @@ const typeDefs = gql`
"""
projectByName(name: String!): Project
"""
Returns Project Object by a display name
"""
projectByDisplayName(name: String!): Project
"""
Returns Group Object by a given name
"""
groupByName(name: String!): Group
"""
Returns Project Object by a given gitUrl (only the first one if there are multiple)
"""
projectByGitUrl(gitUrl: String!): Project
environmentById(name: String!, project: Int!): Environment
"""
Returns Environment Object by a given names
"""
environmentByName(name: String!, project: Int!): Environment
"""
Returns Environment Object by a given openshiftProjectName
Returns Environment Object by a Cluster Name
"""
environmentByOpenshiftProjectName(
openshiftProjectName: String!
): Environment
userCanSshToEnvironment(
openshiftProjectName: String
): Environment
environmentsByClusterName(name: String!): [Environment]
userCanSshToEnvironment(deploymentTargetName: String): Environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploymentTargetName > name assuming above unique name change is applied

deploymentByRemoteId(id: String): Deployment
taskByRemoteId(id: String): Task
"""
Expand All @@ -541,7 +579,7 @@ const typeDefs = gql`
"""
Returns all OpenShift Objects
"""
allOpenshifts: [Openshift]
allDeploymentTargets: [Openshift | Kubernetes]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns DeploymentTarget interface

"""
Returns all Environments matching given filter (all if no filter defined)
"""
Expand Down Expand Up @@ -605,8 +643,8 @@ const typeDefs = gql`
name: String!
gitUrl: String!
subfolder: String
openshift: Int!
openshiftProjectPattern: String
deploymentTarget: DeploymentTarget
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploymentTarget is id or name

namespaceEnvironment: String
activeSystemsDeploy: String
activeSystemsPromote: String
activeSystemsRemove: String
Expand All @@ -630,7 +668,7 @@ const typeDefs = gql`
deployHeadRef: String
deployTitle: String
environmentType: EnvType!
openshiftProjectName: String!
deploymentTargetName: String!
}

input AddOrUpdateEnvironmentStorageInput {
Expand Down Expand Up @@ -741,7 +779,7 @@ const typeDefs = gql`
patch: UpdateTaskPatchInput!
}

input AddOpenshiftInput {
input AddDeploymentTargetInput {
id: Int
name: String!
consoleUrl: String!
Expand All @@ -752,7 +790,7 @@ const typeDefs = gql`
sshPort: String
}

input DeleteOpenshiftInput {
input DeleteDeploymentTargetInput {
name: String!
}

Expand Down Expand Up @@ -847,8 +885,8 @@ const typeDefs = gql`
autoIdle: Int
storageCalc: Int
pullrequests: String
openshift: Int
openshiftProjectPattern: String
deploymentTarget: DeploymentTarget
namespaceEnvironment: String
developmentEnvironmentsLimit: Int
}

Expand All @@ -857,7 +895,7 @@ const typeDefs = gql`
patch: UpdateProjectPatchInput!
}

input UpdateOpenshiftPatchInput {
input UpdateDeploymentTargetPatchInput {
name: String
consoleUrl: String
token: String
Expand All @@ -867,9 +905,9 @@ const typeDefs = gql`
sshPort: String
}

input UpdateOpenshiftInput {
input UpdateDeploymentTargetInput {
id: Int!
patch: UpdateOpenshiftPatchInput!
patch: UpdateDeploymentTargetPatchInput!
}

input UpdateNotificationMicrosoftTeamsPatchInput {
Expand Down Expand Up @@ -931,7 +969,7 @@ const typeDefs = gql`
deployHeadRef: String
deployTitle: String
environmentType: EnvType
openshiftProjectName: String
deploymentTargetName: String
route: String
routes: String
monitoringUrls: String
Expand Down Expand Up @@ -1120,10 +1158,10 @@ const typeDefs = gql`
input: RemoveNotificationFromProjectInput!
): Project
removeAllNotificationsFromAllProjects: String
addOpenshift(input: AddOpenshiftInput!): Openshift
updateOpenshift(input: UpdateOpenshiftInput!): Openshift
deleteOpenshift(input: DeleteOpenshiftInput!): String
deleteAllOpenshifts: String
addDeploymentTarget(input: AddDeploymentTargetInput!): DeploymentTarget
updateDeploymentTarget(input: UpdateDeploymentTargetInput!): DeploymentTarget
deleteDeploymentTarget(input: DeleteDeploymentTargetInput!): String
deleteAllDeploymentTargets: String
addProject(input: AddProjectInput!): Project
updateProject(input: UpdateProjectInput!): Project
deleteProject(input: DeleteProjectInput!): String
Expand Down